home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 23 / Amiga Format AFCD23 (Feb 1998, Issue 107).iso / +look_here_1st!+ / reader_requests / alienbreed3d2 / cheesesauce / abreed3d_2player.s < prev    next >
Text File  |  1997-11-28  |  103KB  |  6,980 lines

  1.  
  2.  
  3. maxscrdiv EQU 8
  4. max3ddiv EQU 5
  5. playerheight EQU 12*1024
  6. scrheight EQU 80
  7.  
  8. xpos EQU 0    ;l
  9. zpos EQU 4    ;l
  10. zsinval EQU 8    ;w
  11. zcosval EQU 10    ;w
  12. ztox EQU 12    ;l
  13. xsinval EQU 16    ;w
  14. xcosval EQU 18    ;w
  15. xspd EQU 20    ;w
  16. zspd EQU 22    ;w
  17. mapx EQU 24    ;b
  18. mapz EQU 25    ;b
  19. whichtile EQU 26 ;b
  20. xofflight EQU 28    ;w
  21. zofflight EQU 30    ;w
  22. offlight EQU 32        ;w
  23. zlinestore EQU 34
  24. zlinedir EQU 38
  25. zposdir EQU 40
  26. zposstore EQU 42
  27. xdiststore EQU 44
  28. xdistdir EQU 46
  29. zwallfound EQU 48
  30.  
  31. xlinestore EQU 50
  32. xlinedir EQU 54
  33. xposdir EQU 56
  34. xposstore EQU 58
  35. zdiststore EQU 60
  36. zdistdir EQU 62
  37. xwallfound EQU 64
  38.  
  39.  
  40. midoffset EQU 104*4*40
  41.  
  42.  SECTION Scrn,CODE 
  43. OpenLib         equ -552
  44. CloseLib        equ -414
  45.  
  46. vhposr        equ $006    
  47. vhposrl        equ $007 
  48. bltcon0        equ $40 
  49. bltcon1        equ $42
  50. bltcpt        equ $48
  51. bltbpt        equ $4c
  52. bltapt        equ $50
  53. spr0ctl        equ $142
  54. spr1ctl        equ $14a
  55. spr2ctl        equ $152
  56. spr3ctl        equ $15a
  57. spr4ctl        equ $162
  58. spr5ctl        equ $16a
  59. spr6ctl        equ $172
  60. spr7ctl        equ $17a
  61. spr0pos        equ $140
  62. spr1pos        equ $148
  63. spr2pos        equ $150
  64. spr3pos        equ $158
  65. spr4pos        equ $160
  66. spr5pos        equ $168
  67. spr6pos        equ $170
  68. spr7pos        equ $178
  69. bltdpt         equ $54
  70. bltafwm        equ $44
  71. bltalwm        equ $46
  72. bltsize         equ $58
  73. bltcmod         equ $60
  74. bltbmod         equ $62
  75. bltamod         equ $64
  76. bltdmod         equ $66
  77. diwstart        equ $8e         ; Screen hardware registers.
  78. diwstop         equ $90
  79. ddfstart        equ $92
  80. ddfstop         equ $94
  81. bplcon0         equ $100
  82. bplcon1         equ $102
  83. col0            equ $180
  84. col1            equ $182
  85. col2        equ $184
  86. col3        equ $186
  87. col4        equ $188
  88. col5        equ $18a
  89. col6        equ $18c
  90. col7        equ $18e
  91. col8            equ $190
  92. col9            equ $192
  93. col10           equ $194
  94. dmacon        equ $96
  95. dmaconr        equ $002
  96. intenar        equ $01c
  97. intena        equ $09a
  98. intreq        equ $09c
  99. intreqr        equ $01e
  100. intreqrl    equ $01f
  101. bpl1pth         equ $e0
  102. bpl1ptl         equ $e2
  103. bpl2pth        equ $e4
  104. bpl2ptl        equ $e6
  105. bpl3pth        equ $e8
  106. bpl3ptl        equ $ea
  107. bpl4pth        equ $ec
  108. bpl4ptl        equ $ee
  109. bpl5pth        equ $f0
  110. bpl5ptl        equ $f2
  111. bpl6pth        equ $f4
  112. bpl6ptl        equ $f6
  113. bpl7pth        equ $f8
  114. bpl7ptl        equ $fa
  115. bpl8pth        equ $fc
  116. bpl8ptl        equ $fe
  117. spr0pth        equ $120
  118. spr0ptl        equ $122
  119. spr1pth        equ $124
  120. spr1ptl        equ $126
  121. spr2pth        equ $128
  122. spr2ptl        equ $12a
  123. spr3pth        equ $12c
  124. spr3ptl        equ $12e
  125. spr4pth        equ $130
  126. spr4ptl        equ $132
  127. spr5pth        equ $134
  128. spr5ptl        equ $136
  129. spr6pth        equ $138
  130. spr6ptl        equ $13a
  131. spr7pth        equ $13c
  132. spr7ptl        equ $13e
  133.  
  134.  
  135. ** This waits for the blitter to finish before allowing program
  136. ** execution to continue.
  137.  
  138. WB MACRO
  139. \@bf:
  140.  btst #6,dmaconr(a6)
  141.  bne.s \@bf
  142.  ENDM
  143.  
  144. *Another version for when d6 <> dff000
  145.  
  146. WBSLOW MACRO
  147. \@bf:
  148.  btst #6,$dff000+dmaconr
  149.  bne.s \@bf
  150.  ENDM
  151.  
  152.  
  153. **
  154.  
  155.  include "macros.i"
  156.  include "ab3:source/defs.i"
  157.  
  158. * Load level into buffers.
  159.  move.l 4.w,a6
  160.  move.l #doslibname,a1
  161.  moveq #0,d0
  162.  jsr -552(a6)
  163.  move.l d0,doslib
  164.  
  165.  move.l d0,a6
  166.  move.l #LDname,d1
  167.  move.l #1005,d2
  168.  jsr -30(a6)
  169.  move.l d0,LDhandle
  170.  
  171.  move.l doslib,a6
  172.  move.l d0,d1
  173.  move.l #LEVELDATA,d2
  174.  move.l #70000,d3
  175.  jsr -42(a6)
  176.  
  177.  move.l doslib,a6
  178.  move.l LDhandle,d1
  179.  jsr -36(a6)
  180.  
  181. ********
  182.  
  183.  move.l doslib,a6
  184.  move.l #LGname,d1
  185.  move.l #1005,d2
  186.  jsr -30(a6)
  187.  move.l d0,LGhandle
  188.  
  189.  move.l doslib,a6
  190.  move.l d0,d1
  191.  move.l #LEVELGRAPHICS,d2
  192.  move.l #25000,d3
  193.  jsr -42(a6)
  194.  
  195.  move.l doslib,a6
  196.  move.l LGhandle,d1
  197.  jsr -36(a6)
  198.  
  199. ********
  200.  
  201.  move.l doslib,a6
  202.  move.l #LCname,d1
  203.  move.l #1005,d2
  204.  jsr -30(a6)
  205.  move.l d0,LChandle
  206.  
  207.  move.l doslib,a6
  208.  move.l d0,d1
  209.  move.l #LEVELCLIPS,d2
  210.  move.l #50000,d3
  211.  jsr -42(a6)
  212.  
  213.  move.l doslib,a6
  214.  move.l LChandle,d1
  215.  jsr -36(a6)
  216.  
  217. *******
  218.  
  219. ********
  220.  
  221.  move.l doslib,a6
  222.  move.l #Prefsname,d1
  223.  move.l #1005,d2
  224.  jsr -30(a6)
  225.  move.l d0,Prefshandle
  226.  
  227.  move.l doslib,a6
  228.  move.l d0,d1
  229.  move.l #Prefsfile,d2
  230.  move.l #50,d3
  231.  jsr -42(a6)
  232.  
  233.  move.l doslib,a6
  234.  move.l Prefshandle,d1
  235.  jsr -36(a6)
  236.  
  237. *******
  238.  
  239.  cmp.b #'s',Prefsfile+2
  240.  seq STEREO
  241.  
  242.  move.l doslib,d0
  243.  move.l d0,a1
  244.  move.l 4.w,a6
  245.  jsr CloseLib(a6)
  246.  
  247.  
  248.  jmp stuff
  249. endstuff:
  250.  
  251.  move.l #$dff000,a6    ; NB V. IMPORTANT: A6=CUSTOM BASE
  252.  move.w #$87c0,dmacon(a6)
  253.  move.w #$8020,dmacon(a6)
  254.  move.w intenar(a6),saveinters
  255.  move.w #$7fff,intena(a6)
  256.  move.w #$00ff,$dff09e
  257.  
  258. *** Put myself in supervisor mode
  259.  
  260.  move.l #blag,$80
  261.  trap #0
  262. ; move.l $6c,d0
  263. ; move.l #blag,$6c
  264. ; move.w #$8010,intreq(a6)
  265.  
  266.  rts
  267.  
  268. saveit: ds.l 10
  269. doslibname: dc.b 'dos.library',0
  270.  even
  271. doslib: dc.l 0
  272.  
  273. LDname: dc.b 'ab3:includes/tstlev.bin',0
  274.  even
  275. LDhandle: dc.l 0
  276. LGname: dc.b 'ab3:includes/tstlev.graph.bin',0
  277.  even
  278. LGhandle: dc.l 0
  279. LCname: dc.b 'ab3:includes/tstlev.clips',0
  280.  even
  281. LChandle: dc.l 0
  282.  
  283. Prefsname: dc.b 'ram:prefs',0
  284.  even
  285. Prefshandle: dc.l 0
  286.  
  287. Prefsfile: ds.b 50
  288.  
  289. blag:
  290. ; move.w #$10,intreq(a6)
  291. ; move.l d0,$6c
  292. ; move.w #$7fff,intena(a6)
  293.  
  294.  move.w #$20,$dff1dc
  295.  
  296.  move.l $6c,saveit
  297.  move.l #Chan0inter,$6c
  298.  jsr KInt_Init
  299.  
  300.  
  301.  
  302. ****************************
  303. * Initialize level
  304. ****************************
  305. * Poke all clip offsets into
  306. * correct bit of level data.
  307. ****************************
  308.  lea.l LEVELGRAPHICS,a0
  309.  move.l 12(a0),a1
  310.  add.l a0,a1
  311.  move.l a1,ZoneGraphAdds
  312.  move.l (a0),a1
  313.  add.l a0,a1
  314.  move.l a1,DoorData
  315.  move.l 4(a0),a1
  316.  add.l a0,a1
  317.  move.l a1,LiftData
  318.  move.l 8(a0),a1
  319.  add.l a0,a1
  320.  move.l a1,SwitchData
  321.  adda.w #16,a0
  322.  move.l a0,ZoneAdds
  323.  
  324.  lea.l LEVELDATA,a1
  325.  move.l 16(a1),a2
  326.  add.l a1,a2
  327.  move.l a2,Points
  328.  move.l 20(a1),a2
  329.  add.l a1,a2
  330.  move.l a2,FloorLines
  331.  move.l 24(a1),a2
  332.  add.l a1,a2
  333.  move.l a2,ObjectData
  334.  move.l 28(a1),a2
  335.  add.l a1,a2
  336.  move.l a2,PlayerShotData
  337.  move.l 32(a1),a2
  338.  add.l a1,a2
  339.  move.l a2,NastyShotData
  340.  move.l 36(a1),a2
  341.  add.l a1,a2
  342.  move.l a2,ObjectPoints  
  343.  move.l 40(a1),a2
  344.  add.l a1,a2
  345.  move.l a2,PLR1_Obj
  346.  move.l 44(a1),a2
  347.  add.l a1,a2
  348.  move.l a2,PLR2_Obj
  349.  move.w 14(a1),NumObjectPoints
  350.  
  351. ; bra noclips
  352.   
  353.  lea.l LEVELCLIPS,a2
  354.  moveq #0,d0
  355.  move.w 10(a1),d7    ;numzones
  356. assignclips:
  357.  move.l (a0)+,a3
  358.  add.l a1,a3    ; pointer to a zone
  359.  adda.w #ToListOfGraph,a3 ; pointer to zonelist
  360. dowholezone:
  361.  tst.w (a3)
  362.  blt.s nomorethiszone
  363.  tst.w 2(a3)
  364.  blt.s thisonenull
  365.  
  366.  move.l d0,d1
  367.  asr.l #2,d1
  368.  move.w d1,2(a3)
  369.  
  370. findnextclip:
  371.  cmp.w #-2,(a2,d0.l)
  372.  beq.s foundnextclip
  373.  addq.l #4,d0
  374.  bra.s findnextclip
  375. foundnextclip
  376.  addq.l #4,d0
  377.  
  378. thisonenull:
  379.  addq #8,a3 
  380.  bra.s dowholezone
  381. nomorethiszone:
  382.  dbra d7,assignclips
  383.  
  384. noclips:
  385.  
  386. * Put in addresses of glowything
  387.  
  388.  move.l red_des,a0
  389.  move.w (a0),d0
  390.  addq #1,d0
  391.  muls #6,d0
  392.  lea 2(a0,d0.w),a1
  393.  move.l red_des+4,a0
  394.  move.l a1,(a0)
  395.  move.w #0,(a1)
  396.  
  397.  move.l yellow_des,a0
  398.  move.w (a0),d0
  399.  addq #1,d0
  400.  muls #6,d0
  401.  lea 2(a0,d0.w),a1
  402.  move.l yellow_des+4,a0
  403.  move.l a1,(a0)
  404.  move.w #0,(a1)
  405.  
  406.  move.l green_des,a0
  407.  move.w (a0),d0
  408.  addq #1,d0
  409.  muls #6,d0
  410.  lea 2(a0,d0.w),a1
  411.  move.l green_des+4,a0
  412.  move.l a1,(a0)
  413.  move.w #0,(a1)
  414.  
  415.  move.l blue_des,a0
  416.  move.w (a0),d0
  417.  addq #1,d0
  418.  muls #6,d0
  419.  lea 2(a0,d0.w),a1
  420.  move.l blue_des+4,a0
  421.  move.l a1,(a0)
  422.  move.w #0,(a1)
  423.  
  424.  
  425. ************************************
  426.  
  427.  cmp.b #'k',Prefsfile
  428.  bne.s nkb
  429.  st PLR1KEYS
  430.  clr.b PLR1PATH
  431.  clr.b PLR1MOUSE
  432.  clr.b PLR1JOY
  433. nkb:
  434.  cmp.b #'m',Prefsfile
  435.  bne.s nmc
  436.  clr.b PLR1KEYS
  437.  clr.b PLR1PATH
  438.  st PLR1MOUSE
  439.  clr.b PLR1JOY
  440. nmc:
  441.  cmp.b #'j',Prefsfile
  442.  bne.s njc
  443.  clr.b PLR1KEYS
  444.  clr.b PLR1PATH
  445.  clr.b PLR1MOUSE
  446.  st PLR1JOY
  447. njc:
  448.  
  449.  move.l #empty,pos1LEFT
  450.  move.l #empty,pos2LEFT
  451.  move.l #empty,pos1RIGHT
  452.  move.l #empty,pos2RIGHT
  453.  move.l #emptyend,Samp0endLEFT
  454.  move.l #emptyend,Samp1endLEFT
  455.  move.l #emptyend,Samp0endRIGHT
  456.  move.l #emptyend,Samp1endRIGHT
  457.  
  458.  move.l #nullspr,d0
  459.  move.w d0,s4l
  460.  move.w d0,s5l
  461.  move.w d0,s6l
  462.  move.w d0,s7l
  463.  swap d0
  464.  move.w d0,s4h
  465.  move.w d0,s5h
  466.  move.w d0,s6h
  467.  move.w d0,s7h 
  468.  
  469.  move.l #nullline,d0
  470.  move.w d0,n1l
  471.  swap d0
  472.  move.w d0,n1h
  473.  
  474.  move.l #Panel,d0
  475.  move.w d0,p1l
  476.  swap d0
  477.  move.w d0,p1h
  478.  move.l #Panel+40,d0
  479.  move.w d0,p2l
  480.  swap d0
  481.  move.w d0,p2h
  482.  move.l #Panel+40*2,d0
  483.  move.w d0,p3l
  484.  swap d0
  485.  move.w d0,p3h
  486.  move.l #Panel+40*3,d0
  487.  move.w d0,p4l
  488.  swap d0
  489.  move.w d0,p4h
  490.  move.l #Panel+40*4,d0
  491.  move.w d0,p5l
  492.  swap d0
  493.  move.w d0,p5h
  494.  move.l #Panel+40*5,d0
  495.  move.w d0,p6l
  496.  swap d0
  497.  move.w d0,p6h
  498.  move.l #Panel+40*6,d0
  499.  move.w d0,p7l
  500.  swap d0
  501.  move.w d0,p7h
  502.  move.l #Panel+40*7,d0
  503.  move.w d0,p8l
  504.  swap d0
  505.  move.w d0,p8h
  506.  
  507. *******************************
  508. * TIMER SCREEN SETUP
  509. ; move.l #TimerScr,d0
  510. ; move.w d0,p1l
  511. ; swap d0
  512. ; move.w d0,p1h
  513. ; move.w #$1201,Panelcon
  514.  
  515.  move.l #borders,d0
  516.  move.w d0,s0l
  517.  swap d0
  518.  move.w d0,s0h
  519.  move.l #borders+2592,d0
  520.  move.w d0,s1l
  521.  swap d0
  522.  move.w d0,s1h
  523.  move.l #borders+2592*2,d0
  524.  move.w d0,s2l
  525.  swap d0
  526.  move.w d0,s2h
  527.  move.l #borders+2592*3,d0
  528.  move.w d0,s3l
  529.  swap d0
  530.  move.w d0,s3h
  531.  
  532.  move.w #52*256+64,borders
  533.  move.w #212*256+0,borders+8
  534.  move.w #52*256+64,borders+2592
  535.  move.w #212*256+128,borders+8+2592
  536.  move.w #52*256+192,borders+2592*2
  537.  move.w #212*256+0,borders+8+2592*2
  538.  move.w #52*256+192,borders+2592*3
  539.  move.w #212*256+128,borders+8+2592*3
  540.  
  541.  move.l #FacePlace,d0
  542.  move.w d0,f1l
  543.  swap d0
  544.  move.w d0,f1h
  545.  move.l #FacePlace+32*24,d0
  546.  move.w d0,f2l
  547.  swap d0
  548.  move.w d0,f2h
  549.  move.l #FacePlace+32*24*2,d0
  550.  move.w d0,f3l
  551.  swap d0
  552.  move.w d0,f3h
  553.  move.l #FacePlace+32*24*3,d0
  554.  move.w d0,f4l
  555.  swap d0
  556.  move.w d0,f4h
  557.  move.l #FacePlace+32*24*4,d0
  558.  move.w d0,f5l
  559.  swap d0
  560.  move.w d0,f5h
  561.  
  562.  move.l #PanelCop,d0
  563.  move.w d0,pcl1
  564.  move.w d0,pcl2
  565.  swap d0
  566.  move.w d0,pch1
  567.  move.w d0,pch2
  568.  
  569.  move.l #bigfield,d0
  570.  move.w d0,ocl
  571.  swap d0
  572.  move.w d0,och
  573.  
  574.  bset.b #1,$bfe001
  575.  
  576.  move.l #bigfield,$dff080    ; Point the copper at our copperlist.
  577.  move.l #$dff000,a6    ; a6 points at the first custom chip register.
  578.  move.w #$00ff,$dff09e
  579.  
  580. ; move.l #Blurbfield,$dff080
  581.  
  582.  move.w #0,d0
  583.  
  584.  move.l #scrn,d0
  585.  move.w d0,pl1l
  586.  swap d0
  587.  move.w d0,pl1h
  588.  
  589.  move.l #scrn+40,d0
  590.  move.w d0,pl2l
  591.  swap d0
  592.  move.w d0,pl2h
  593.  
  594.  move.l #scrn+80,d0
  595.  move.w d0,pl3l
  596.  swap d0
  597.  move.w d0,pl3h
  598.  
  599.  move.l #scrn+120,d0
  600.  move.w d0,pl4l
  601.  swap d0
  602.  move.w d0,pl4h
  603.  
  604.  move.l #scrn+160,d0
  605.  move.w d0,pl5l
  606.  swap d0
  607.  move.w d0,pl5h
  608.  
  609.  move.l #scrn+200,d0
  610.  move.w d0,pl6l
  611.  swap d0
  612.  move.w d0,pl6h
  613.  
  614.  move.l #scrn+240,d0
  615.  move.w d0,pl7l
  616.  swap d0
  617.  move.w d0,pl7h
  618.  
  619.  move.l #healthpal,a5
  620.  move.l #colbars,a0
  621.  move.l #colbars2,a2
  622.  move.w #scrheight-1,d0
  623.  move.l #0,d6
  624.  move.w #0,d3
  625.  move.w #$2bdf,startwait
  626.  move.w #$2d01,endwait
  627. fillcop
  628.  move.w #$180,d1
  629.  
  630.  move.l a0,a1
  631.  move.l a2,a3
  632.  move.w #$10c,(a1)+
  633.  move.w #$10c,(a3)+
  634.  move.w d3,(a1)+
  635.  move.w d3,(a3)+
  636.  eor.w #$8000,d3
  637.  
  638.  move.w #$106,(a1)+
  639.  move.w #$106,(a3)+
  640.  move.w #$2c42,d5
  641.  or.w d3,d5
  642.  and.w #$fffe,d5
  643.  move.w d5,(a1)+
  644.  move.w d5,(a3)+
  645.  bsr do32
  646.  
  647.  move.w #$106,(a1)+
  648.  move.w #$106,(a3)+
  649.  move.w #$4c42,d5
  650.  or.w d3,d5
  651.  and.w #$fffe,d5
  652.  move.w d5,(a1)+
  653.  move.w d5,(a3)+
  654.  bsr do32
  655.  
  656.  move.w #$106,(a1)+
  657.  move.w #$106,(a3)+
  658.  move.w #$6c42,d5
  659.  or.w d3,d5
  660.  and.w #$fffe,d5
  661.  move.w d5,(a1)+
  662.  move.w d5,(a3)+
  663.  bsr do32
  664.  
  665. **********************************
  666.  
  667.  cmp.b #'s',option
  668.  bra.s smallscrn
  669.  
  670.  move.w startwait,(a1)+
  671.  move.w #$fffe,(a1)+
  672.  move.w endwait,(a1)+
  673.  move.w #$ff00,(a1)+
  674.  move.w startwait,(a3)+
  675.  move.w #$fffe,(a3)+
  676.  move.w endwait,(a3)+
  677.  move.w #$ff00,(a3)+
  678.  
  679.  
  680.  add.w #$300,startwait
  681.  add.w #$300,endwait
  682.  
  683. smallscrn: 
  684.  
  685.  move.l #$1060c42,(a1)+
  686.  move.l #$1060c42,(a3)+
  687.  move.w #$19e,(a1)+
  688.  move.w (a5),(a1)+
  689.  move.w #$19e,(a3)+
  690.  move.w (a5)+,(a3)+
  691.  
  692. **********************************
  693.  
  694.  adda.w #104*4,a0
  695.  adda.w #104*4,a2
  696.  
  697.  dbra d0,fillcop
  698.  
  699. **********************************
  700.  cmp.b #'s',option
  701.  bra smallnotlarge
  702.  move.w #$38,fetchstart
  703.  move.w #$b8,fetchstop
  704.  move.w #$2c81,winstart
  705.  move.w #$2cc1,winstop
  706.  move.w #-40,modulo
  707.  move.w #-40,modulo+4
  708.  
  709.  move.l #scrn+40,a0
  710.  move.l #scrn+160,a1
  711.  move.l #scrn+280,a2
  712.  move.l #scrntab,a3
  713.  move.w #319,d7    ; counter
  714.  move.w #0,d1    ; xpos
  715. plotscrnloop:
  716.  move.b (a3)+,d0
  717.  move.w d1,d2
  718.  asr.w #3,d2
  719.  move.b d1,d3
  720.  not.b d3
  721.  bclr.b d3,-40(a0,d2.w)
  722.  bclr.b d3,(a0,d2.w)
  723.  bclr.b d3,40(a0,d2.w)
  724.  bclr.b d3,-40(a1,d2.w)
  725.  bclr.b d3,(a1,d2.w)
  726.  bclr.b d3,40(a1,d2.w)
  727.  bclr.b d3,-40(a2,d2.w)
  728.  btst #0,d0
  729.  beq.s nobp1
  730.  bset.b d3,-40(a0,d2.w)
  731. nobp1:
  732.  btst #1,d0
  733.  beq.s nobp2
  734.  bset.b d3,(a0,d2.w)
  735. nobp2:
  736.  btst #2,d0
  737.  beq.s nobp3
  738.  bset.b d3,40(a0,d2.w)
  739. nobp3:
  740.  btst #3,d0
  741.  beq.s nobp4
  742.  bset.b d3,-40(a1,d2.w)
  743. nobp4:
  744.  btst #4,d0
  745.  beq.s nobp5
  746.  bset.b d3,(a1,d2.w)
  747. nobp5:
  748.  btst #5,d0
  749.  beq.s nobp6
  750.  bset.b d3,40(a1,d2.w)
  751. nobp6:
  752.  btst #6,d0
  753.  beq.s nobp7
  754.  bset.b d3,-40(a2,d2.w)
  755. nobp7:
  756.  
  757.  addq #1,d1
  758.  
  759.  dbra d7,plotscrnloop
  760.  
  761. smallnotlarge:
  762.  
  763. **********************************
  764.  
  765. ****************************
  766.  jsr INITPLAYER
  767. ; bsr initobjpos
  768. ****************************
  769.  
  770.  move.l #null,$dff0a0
  771.  move.w #100,$dff0a4
  772.  move.w #443,$dff0a6
  773.  move.w #63,$dff0a8
  774.  
  775.  move.l #null2,$dff0b0
  776.  move.w #100,$dff0b4
  777.  move.w #443,$dff0b6
  778.  move.w #63,$dff0b8
  779.  
  780.  move.l #null4,$dff0c0
  781.  move.w #100,$dff0c4
  782.  move.w #443,$dff0c6
  783.  move.w #63,$dff0c8
  784.  
  785.  move.l #null3,$dff0d0
  786.  move.w #100,$dff0d4
  787.  move.w #443,$dff0d6
  788.  move.w #63,$dff0d8
  789.  
  790.  move.l #tab,a1
  791.  move.w #64,d7
  792.  move.w #0,d6
  793. outerlop
  794.  move.l #pretab,a0
  795.  move.w #255,d5
  796. scaledownlop:
  797.  move.b (a0)+,d0
  798.  ext.w d0
  799.  ext.l d0
  800.  muls d6,d0
  801.  asr.l #6,d0
  802.  move.b d0,(a1)+
  803.  dbra d5,scaledownlop
  804.  addq #1,d6
  805.  dbra d7,outerlop
  806.  
  807.  move.l #$dff000,a6
  808.  
  809.  move.w #$c018,intena(a6)
  810.  
  811.  move.w #$f,dmacon(a6)
  812.  move.w #$820f,dmacon(a6)
  813.  
  814.  bsr FullEnergy
  815.  move.w #63,OldAmmo
  816.  move.w #0,Ammo
  817.  bsr AmmoBar
  818.  move.w #0,OldAmmo
  819.  
  820.  move.b #1,PLR1_GunDamage
  821.  move.b #1,PLR2_GunDamage
  822.  move.w #3,PLR1_GunNoise
  823.  move.w #3,PLR2_GunNoise
  824.  
  825.  move.w #10,GunData    ; 10 shots pistol
  826.  st GunData+7
  827.  clr.b GunData+8+7
  828.  clr.w GunData+8
  829.  move.b #0,GunSelected
  830.  
  831. ; move.w #$20,$1dc(a6)
  832.  
  833.  move.w #$0,$dff034
  834.  move.w #0,Conditions
  835.  move.l #KeyMap,a5
  836.  clr.b $45(a5)
  837.  
  838.  move.l #ingame,mt_data
  839.  clr.b UseAllChannels
  840.  
  841.  cmp.b #'b',Prefsfile+3
  842.  bne.s .noback
  843.  jsr mt_init
  844. .noback:
  845.  st doanything
  846.  clr.b CHANNELDATA
  847.  clr.b CHANNELDATA+8
  848.  clr.b CHANNELDATA+16
  849.  clr.b CHANNELDATA+24
  850.  
  851.  cmp.b #'b',Prefsfile+3
  852.  bne.s noreserve
  853.  
  854.  st CHANNELDATA
  855.  st CHANNELDATA+8
  856.  st CHANNELDATA+16
  857.  st CHANNELDATA+24
  858.  
  859. noreserve:
  860.  
  861. lop: 
  862.  
  863.  move.l #$dff000,a6
  864.  
  865.  move.l drawpt,d0
  866.  move.l olddrawpt,drawpt
  867.  move.l d0,olddrawpt
  868.  move.l d0,$dff084
  869.  move.l drawpt,a3
  870.  adda.w #10,a3
  871.  move.l a3,frompt
  872.  add.l #104*4*40,a3
  873.  move.l a3,midpt
  874.  
  875. waitfortop:
  876.  btst.b #0,intreqrl(a6)
  877.  beq waitfortop
  878.  move.w #$1,intreq(a6)
  879.  
  880.  move.b SpaceTapped,SPCTAP
  881.  clr.b SpaceTapped
  882.  
  883.  move.l waterpt,a0
  884.  move.l (a0)+,watertouse
  885.  cmp.l #endwaterlist,a0
  886.  blt.s okwat
  887.  move.l #waterlist,a0
  888. okwat:
  889.  move.l a0,waterpt
  890.  
  891.  add.w #640,wtan
  892.  and.w #8191,wtan
  893.  add.w #1,wateroff
  894.  and.w #63,wateroff
  895.  
  896.  move.w FramesToDraw,TempFrames
  897.  move.w #0,FramesToDraw
  898.  
  899.  lea GunData,a6
  900.  moveq #0,d0
  901.  move.b GunSelected,d0
  902.  lea (a6,d0.w*8),a6
  903.  move.w (a6),Ammo
  904.  
  905.  JSR INITTIMER
  906.  
  907.  bsr PLR1_Control
  908.  
  909. ; bsr PLR2_Control
  910.  
  911. ******************************************
  912.  jsr objmoveanim
  913.  bsr PlaceFace
  914.  bsr EnergyBar
  915.  bsr AmmoBar
  916.  clr.b PLR1_clicked
  917.  clr.b PLR2_clicked
  918. ******************************************
  919.  
  920.  move.l ObjectPoints,a1
  921.  move.l PLR1_Obj,a0
  922.  move.b damagetaken(a0),d2
  923.  beq notbeenshot
  924.  ext.w d2
  925.  sub.w d2,Energy
  926.  move.b #0,damagetaken(a0)
  927.  move.l #Cheese,FacesPtr
  928.  move.w #3,Cheese
  929.  move.w #-1,FacesCounter
  930. notbeenshot:
  931.  move.b Energy+1,numlives(a0)
  932.  
  933.  move.w (a0),d0
  934.  move.l PLR1_xoff,(a1,d0.w*8)
  935.  move.l PLR1_zoff,4(a1,d0.w*8)
  936.  move.l PLR1_Roompt,a1
  937.  move.w (a1),12(a0)
  938.  move.l PLR1_yoff,d0
  939.  add.l #playerheight+128*24,d0
  940.  asr.l #7,d0
  941.  move.w d0,4(a0)
  942.  
  943.  move.l ObjectPoints,a1
  944.  move.l PLR2_Obj,a0
  945.  move.w (a0),d0
  946.  move.l PLR2_xoff,(a1,d0.w*8)
  947.  move.l PLR2_zoff,4(a1,d0.w*8)
  948.  move.l PLR2_Roompt,a1
  949. ************************
  950.  move.w #-1,12(a0)
  951.  move.w 10(a1),2(a0)
  952. ************************
  953.  move.l PLR2_yoff,d0
  954.  add.l #playerheight+128*24,d0
  955.  asr.l #7,d0
  956.  move.w d0,4(a0)
  957.  
  958.  
  959.  move.w #0,scaleval
  960.  
  961.  move.l PLR1_xoff,xoff
  962.  move.l PLR1_yoff,yoff
  963.  move.l PLR1_zoff,zoff
  964.  move.w PLR1_angpos,angpos
  965.  move.l PLR1_ListOfGraphRooms,ListOfGraphRooms
  966.  move.l PLR1_PointsToRotatePtr,PointsToRotatePtr
  967.  move.l PLR1_Roompt,Roompt
  968.  
  969.  move.w #0,leftclip
  970.  move.w #96,rightclip
  971.  move.w #0,deftopclip
  972.  move.w #79,defbotclip
  973.  move.w #0,topclip
  974.  move.w #79,botclip
  975. ; sub.l #10*104*4,frompt
  976. ; sub.l #10*104*4,midpt
  977.  
  978. * Subroom loop
  979.  
  980.  bsr DrawDisplay
  981.  
  982.  bra noglass
  983.  
  984. ************************************
  985. * Test glass routine:
  986. ************************************
  987.  
  988.  move.l #WorkSpace,a0
  989.  move.l frompt,a2
  990.  move.w #104*4,d3
  991.  move.w #1,d6
  992. ribl
  993.  move.w #31,d0
  994. readinto
  995.  move.w #15,d1
  996.  move.l a2,a1
  997. readintodown
  998.  move.w (a1),(a0)+
  999.  adda.w d3,a1
  1000.  move.w (a1),(a0)+
  1001.  adda.w d3,a1
  1002.  move.w (a1),(a0)+
  1003.  adda.w d3,a1
  1004.  move.w (a1),(a0)+
  1005.  adda.w d3,a1
  1006.  dbra d1,readintodown
  1007. ; add.w #256-128,a0
  1008.  addq #4,a2
  1009.  dbra d0,readinto
  1010.  addq #4,a2
  1011.  dbra d6,ribl
  1012.  
  1013. * We now have the screen in a buffer
  1014. * for squidging.
  1015.  
  1016.  move.l frompt,a2
  1017.  move.l #WorkSpace,a0
  1018.  move.l glassballpt,a3
  1019.  move.w #$fff,d7
  1020.  move.w #1,d6 
  1021. rfbl:
  1022.  move.w #31,d0
  1023. readoutfrom:
  1024.  move.w #15,d1
  1025.  move.l a2,a1
  1026.  moveq.w #0,d5
  1027. readoutfromdown:
  1028.  move.w (a3)+,d2
  1029.  beq.s nono1
  1030. ; add.w d5,d2
  1031.  move.w (a0,d2.w*2),d2
  1032.  and.w d7,d2
  1033.  move.w d2,(a1)
  1034. nono1:
  1035.  addq #1,d5
  1036.  add.w d3,a1
  1037.  move.w (a3)+,d2
  1038.  beq.s nono2
  1039. ; add.w d5,d2
  1040.  move.w (a0,d2.w*2),d2
  1041.  and.w d7,d2
  1042.  move.w d2,(a1)
  1043. nono2:
  1044.  addq #1,d5
  1045.  add.w d3,a1
  1046.  move.w (a3)+,d2
  1047.  beq.s nono3
  1048. ; add.w d5,d2
  1049.  move.w (a0,d2.w*2),d2
  1050.  and.w d7,d2
  1051.  move.w d2,(a1)
  1052. nono3:
  1053.  addq #1,d5
  1054.  add.w d3,a1
  1055.  move.w (a3)+,d2
  1056.  beq.s nono4
  1057. ; add.w d5,d2
  1058.  move.w (a0,d2.w*2),d2
  1059.  and.w d7,d2
  1060.  move.w d2,(a1)
  1061. nono4:
  1062.  addq #1,d5
  1063.  add.w d3,a1
  1064.  dbra d1,readoutfromdown
  1065.  addq #4,a2
  1066. ; adda.w #128,a0
  1067.  dbra d0,readoutfrom
  1068.  addq #4,a2
  1069.  dbra d6,rfbl
  1070.  
  1071.  move.l glassballpt,d0
  1072.  add.l #64*64*2,d0
  1073.  cmp.l #endglass,d0
  1074.  blt notoffglass
  1075.  move.l #glassball,d0
  1076. notoffglass
  1077.  move.l d0,glassballpt
  1078.  
  1079. noglass:
  1080.  
  1081.  tst.b PLR2
  1082.  bra.s nodrawp2
  1083.  
  1084.  
  1085.  move.l PLR2_xoff,xoff
  1086.  move.l PLR2_yoff,yoff
  1087.  move.l PLR2_zoff,zoff
  1088.  move.w PLR2_angpos,angpos
  1089.  move.l PLR2_ListOfGraphRooms,ListOfGraphRooms
  1090.  move.l PLR2_PointsToRotatePtr,PointsToRotatePtr
  1091.  
  1092.  move.w #0,leftclip
  1093.  move.w #96,rightclip
  1094.  move.w #10,deftopclip
  1095.  move.w #69,defbotclip
  1096.  add.l #68*104*4,frompt
  1097.  add.l #68*104*4,midpt
  1098.  
  1099.  bsr DrawDisplay
  1100.  
  1101.  
  1102. nodrawp2:
  1103.  
  1104. ; move.l #brightentab,a0
  1105. ; move.l frompt,a3
  1106. ; adda.w #(4*33)+(104*4*20),a3
  1107. ; move.w #20,d7
  1108. ; move.w #20,d6
  1109. ;horl:
  1110. ; move.w d6,d5
  1111. ; move.l a3,a1
  1112. ;vertl
  1113. ; move.w (a1),d0
  1114. ; move.w (a0,d0.w*2),(a1)
  1115. ; addq #4,a1
  1116. ; dbra d5,vertl
  1117. ; adda.w #104*4,a3
  1118. ; dbra d7,horl
  1119.  
  1120.  move.l #$dff000,a6
  1121.  
  1122. ; move.w #$300,col0(a6)
  1123.  
  1124.  move.l #KeyMap,a5
  1125.  tst.b $45(a5)
  1126.  beq.s noend
  1127. waitrel
  1128.  btst #7,$bfe001
  1129.  beq.s waitrel
  1130.  bra end
  1131. noend:
  1132.  
  1133.  tst.w Energy
  1134.  bgt .noend
  1135.  cmp.b #'i',option+4
  1136.  bne end
  1137.  move.w #10,Energy
  1138. .noend:
  1139.  
  1140.  move.l SwitchData,a0
  1141.  tst.b 24+8(a0)
  1142.  bne end
  1143.  
  1144.  JSR STOPTIMER
  1145.  
  1146.  bra lop
  1147.  
  1148. ***************************************************************************
  1149. ***************************************************************************
  1150. ****************** End of Main Loop here ********************************** 
  1151. ***************************************************************************
  1152. ***************************************************************************
  1153.  
  1154. GunSelected: dc.b 0
  1155.  even
  1156.  
  1157. GunData:
  1158. ; 0=Pistol 1=Big Gun
  1159. ; ammoleft,ammopershot(b),gunnoise(b),ammoinclip(w)
  1160. ; damage,gotgun(b)
  1161.  
  1162.  dc.w 0
  1163.  dc.b 1,3
  1164.  dc.w 20
  1165.  dc.b 1,$ff
  1166.  
  1167.  dc.w 0
  1168.  dc.b 2,1
  1169.  dc.w 40
  1170.  dc.b 4,0
  1171.  
  1172. protA: dc.w 0
  1173.  
  1174. Path:
  1175. ; incbin "testpath"
  1176. endpath:
  1177. pathpt: dc.l Path
  1178.  
  1179. PLR1KEYS: dc.b 0
  1180. PLR1PATH: dc.b 0
  1181. PLR1MOUSE: dc.b -1
  1182. PLR1JOY: dc.b 0
  1183.  
  1184.  even
  1185.  
  1186. Bobble: dc.w 0
  1187. xwobble: dc.l 0
  1188. xwobxoff: dc.w 0
  1189. xwobzoff: dc.w 0
  1190.  
  1191. PLR1_Control:
  1192.  
  1193. ; Take a snapshot of everything.
  1194.  
  1195.  move.l PLR1_xoff,d2
  1196.  move.l d2,PLR1_oldxoff
  1197.  move.l d2,oldx
  1198.  move.l PLR1_zoff,d3
  1199.  move.l d3,PLR1_oldzoff
  1200.  move.l d3,oldz
  1201.  move.l PLR1s_xoff,d0
  1202.  move.l d0,PLR1_xoff
  1203.  move.l d0,newx
  1204.  move.l PLR1s_zoff,d1
  1205.  move.l d1,newz
  1206.  move.l d1,PLR1_zoff
  1207.  sub.l d2,d0
  1208.  sub.l d3,d1
  1209.  move.l d0,xdiff
  1210.  move.l d1,zdiff
  1211.  move.w PLR1s_sinval,PLR1_sinval
  1212.  move.w PLR1s_cosval,PLR1_cosval
  1213.  move.w PLR1s_angpos,PLR1_angpos
  1214.  move.l PLR1s_yoff,d0
  1215.  move.l #SineTable,a1
  1216.  move.w Bobble,d1
  1217.  move.w (a1,d1.w),d1
  1218.  move.w d1,d3
  1219.  ble.s notnegative
  1220.  neg.w d1
  1221. notnegative:
  1222.  add.w #16384,d1
  1223.  asr.w #5,d1
  1224.  move.w d1,d2
  1225.  add.w d1,d1
  1226.  add.w d2,d1
  1227.  ext.l d1
  1228.  add.l d1,d0
  1229.  
  1230.  asr.w #5,d3
  1231.  ext.l d3
  1232.  move.l d3,xwobble
  1233.  move.w PLR1_sinval,d1
  1234.  muls d3,d1
  1235.  move.w PLR1_cosval,d2
  1236.  muls d3,d2
  1237.  swap d1
  1238.  swap d2
  1239.  asr.w #6,d1
  1240.  move.w d1,xwobxoff
  1241.  asr.w #6,d2
  1242.  neg.w d2
  1243.  move.w d2,xwobzoff
  1244.  
  1245.  
  1246.  move.l d0,PLR1_yoff
  1247.  move.l d0,newy
  1248.  move.l #playerheight,thingheight
  1249.  move.l #40*256,StepUpVal
  1250.  
  1251.  move.l PLR1_Roompt,objroom
  1252.  move.w #%100000000,wallflags
  1253.  
  1254.  bsr MoveObject
  1255.  move.w #0,wallflags
  1256.  move.l objroom,PLR1_Roompt
  1257.  move.w newx,PLR1_xoff
  1258.  move.w newz,PLR1_zoff
  1259.  move.l PLR1_xoff,PLR1s_xoff
  1260.  move.l PLR1_zoff,PLR1s_zoff
  1261.  
  1262.  move.l PLR1_Roompt,a0
  1263.  move.l 2(a0),d0
  1264.  adda.w #ToZonePts,a0
  1265.  sub.l #playerheight,d0
  1266.  move.l d0,PLR1s_tyoff
  1267.  
  1268. ; move.l (a0),a0        ; jump to viewpoint list
  1269.  * A0 is pointing at a pointer to list of points to rotate
  1270.  move.w (a0)+,d1
  1271.  ext.l d1
  1272.  add.l PLR1_Roompt,d1
  1273.  move.l d1,PLR1_PointsToRotatePtr
  1274.  tst.w (a0)+
  1275.  beq.s nobackgraphics
  1276.  move.l a0,-(a7)
  1277.  jsr putinbackdrop 
  1278.  move.l (a7)+,a0
  1279. nobackgraphics:
  1280.  move.l a0,PLR1_ListOfGraphRooms
  1281.  
  1282. *****************************************************
  1283.  
  1284.  rts
  1285.  
  1286. KeyMap: ds.b 256
  1287.  
  1288. PLR2_Control:
  1289.  move.l #SineTable,a0
  1290.  
  1291.  bsr turnleftright
  1292.  
  1293.  move.w PLR2_angspd,d1
  1294.  move.w PLR2_angpos,d0
  1295.  move.w (a0,d0.w),PLR2_sinval
  1296.  adda.w #2048,a0
  1297.  move.w (a0,d0.w),PLR2_cosval
  1298.  
  1299.  move.l PLR2_xspdval,d6
  1300.  move.l PLR2_zspdval,d7
  1301.  
  1302.  move.w PLR2_xoff,oldxoff
  1303.  move.w PLR2_zoff,oldzoff
  1304.  
  1305.  neg.l d6
  1306.  ble.s .nobug1
  1307.  asr.l #1,d6
  1308.  add.l #1,d6
  1309.  bra.s .bug1
  1310. .nobug1
  1311.  asr.l #1,d6
  1312. .bug1:
  1313.  
  1314. ; beq.s goinnowhere
  1315. ; blt.s goinfor
  1316. ; cmp.l #4*65536,d6
  1317. ; ble.s goinnowhere
  1318. ; move.l #4*65536,d6
  1319. ;goinfor:
  1320. ; cmp.l #-4*65536,d6
  1321. ; bge.s goinnowhere
  1322. ; move.l #-4*65536,d6
  1323. ;goinnowhere:
  1324.  
  1325.  neg.l d7
  1326.  ble.s .nobug2
  1327.  asr.l #1,d7
  1328.  add.l #1,d7
  1329.  bra.s .bug2
  1330. .nobug2
  1331.  asr.l #1,d7
  1332. .bug2: 
  1333.  
  1334. ; beq.s goinnowhere2
  1335. ; blt.s goinfor2
  1336. ; cmp.l #4*65536,d7
  1337. ; ble.s goinnowhere2
  1338. ; move.l #4*65536,d7
  1339. ;goinfor2:
  1340. ; cmp.l #-4*65536,d7
  1341. ; bge.s goinnowhere2
  1342. ; move.l #-4*65536,d7
  1343. ;goinnowhere2:
  1344.  
  1345.  move.w PLR2_sinval,d1
  1346.  move.w PLR2_cosval,d2
  1347.  move.w PLR2_ForwardSpd,d3
  1348.  
  1349.  muls d3,d2
  1350.  muls d3,d1
  1351.  
  1352.  sub.l d1,d6
  1353.  sub.l d2,d7
  1354.  add.l PLR2_pushx,d6
  1355.  add.l PLR2_pushz,d7 
  1356.  add.l d6,PLR2_xspdval
  1357.  add.l d7,PLR2_zspdval
  1358.  move.l PLR2_xspdval,d6
  1359.  move.l PLR2_zspdval,d7
  1360.  add.l d6,PLR2_xoff
  1361.  add.l d7,PLR2_zoff
  1362.  
  1363.  move.w PLR2_xoff,newx
  1364.  move.w PLR2_zoff,newz
  1365.  move.w oldxoff,oldx
  1366.  move.w oldzoff,oldz
  1367.  move.l PLR2_xspdval,xdiff
  1368.  move.l PLR2_zspdval,zdiff
  1369.  move.l PLR2_Roompt,objroom
  1370.  move.w #%100000000,wallflags
  1371.  bsr MoveObject
  1372.  move.w #0,wallflags
  1373.  move.l objroom,PLR2_Roompt
  1374.  move.w newx,PLR2_xoff
  1375.  move.w newz,PLR2_zoff
  1376.  
  1377.  move.l PLR2_xoff,d0
  1378.  move.l PLR2_zoff,d1
  1379.  sub.l oldxoff,d0
  1380.  sub.l oldzoff,d1
  1381.  move.l #0,PLR2_pushx
  1382.  move.l #0,PLR2_pushz
  1383.  move.l d0,PLR2_opushx
  1384.  move.l d1,PLR2_opushz
  1385.  
  1386.  move.l PLR2_Roompt,a0
  1387.  move.l 2(a0),d0
  1388.  sub.l #playerheight,d0
  1389.  move.l d0,PLR2_tyoff
  1390.  adda.w #22,a0
  1391.  
  1392. ; move.l (a0),a0        ; jump to viewpoint list
  1393.  * A0 is pointing at a pointer to list of points to rotate
  1394.  move.l (a0)+,PLR2_PointsToRotatePtr
  1395.  move.l a0,PLR2_ListOfGraphRooms
  1396.  
  1397. *****************************************************
  1398.  
  1399.  move.l PLR2_tyoff,d0
  1400.  move.l PLR2_yoff,d1
  1401.  move.l PLR2_yvel,d2
  1402.  add.l d2,d1
  1403.  add.l #1024,d2
  1404.  sub.l d1,d0
  1405.  bgt.s .shouldfall
  1406.  move.l #0,d2
  1407.  add.l d0,d1
  1408. .shouldfall:
  1409.  move.l d2,PLR2_yvel
  1410.  move.l d1,PLR2_yoff
  1411.  rts
  1412.  
  1413.  
  1414. DrawDisplay:
  1415.  
  1416.  move.l #SineTable,a0
  1417.  move.w angpos,d0
  1418.  move.w (a0,d0.w),d6
  1419.  adda.w #2048,a0
  1420.  move.w (a0,d0.w),d7
  1421.  move.w d6,sinval
  1422.  move.w d7,cosval
  1423.  
  1424.  move.l yoff,d0
  1425.  asr.l #8,d0
  1426.  move.w d0,d1
  1427.  and.w #63,d1
  1428.  move.w d1,wallyoff
  1429.  asl.w #2,d0
  1430.  move.w d0,flooryoff
  1431.  
  1432.  move.w xoff,d6
  1433.  move.w d6,d3
  1434.  asr.w #1,d3
  1435.  add.w d3,d6
  1436.  asr.w #1,d6
  1437.  move.w d6,xoff34
  1438.  
  1439.  move.w zoff,d6
  1440.  move.w d6,d3
  1441.  asr.w #1,d3
  1442.  add.w d3,d6
  1443.  asr.w #1,d6
  1444.  move.w d6,zoff34
  1445.  
  1446.  bsr RotateLevelPts
  1447.  bsr RotateObjectPts
  1448.  bsr OrderZones
  1449.  
  1450.  move.l ListOfGraphRooms,a0
  1451.  
  1452.  move.l endoflist,a0
  1453. subroomloop:
  1454.  move.w -(a0),d7
  1455.  blt jumpoutofrooms
  1456.  
  1457. ; bsr setlrclip
  1458. ; move.w leftclip,d0
  1459. ; cmp.w rightclip,d0
  1460. ; bge subroomloop
  1461.  move.l a0,-(a7)
  1462.  move.l ZoneGraphAdds,a0
  1463.  move.l (a0,d7.w*4),a0
  1464.  add.l #LEVELGRAPHICS,a0
  1465.  move.l a0,ThisRoomToDraw
  1466.  
  1467.  move.l ListOfGraphRooms,a1
  1468.  
  1469. finditit:
  1470.  tst.w (a1)
  1471.  blt nomoretodoatall
  1472.  cmp.w (a1),d7
  1473.  beq outoffind
  1474.  adda.w #8,a1
  1475.  bra finditit
  1476.  
  1477. outoffind:
  1478.  
  1479.  move.l a1,-(a7)
  1480.  
  1481.  move.w #0,leftclip
  1482.  move.w #96,rightclip
  1483.  moveq #0,d7
  1484.  move.w 2(a1),d7
  1485.  blt.s outofrcliplop
  1486.  move.l #LEVELCLIPS,a0
  1487.  lea (a0,d7.l*4),a0
  1488.  
  1489.  tst.w (a0)
  1490.  blt outoflcliplop
  1491.  
  1492.  bsr NEWsetlclip
  1493.  
  1494. intolcliplop:        ; clips
  1495.  tst.w (a0)
  1496.  blt outoflcliplop
  1497.  
  1498.  bsr NEWsetlclip 
  1499.  bra intolcliplop
  1500.  
  1501. outoflcliplop:
  1502.  
  1503.  addq #4,a0
  1504.  
  1505.  tst.w (a0)
  1506.  blt outofrcliplop
  1507.  
  1508.  bsr NEWsetrclip
  1509.  
  1510. intorcliplop:        ; clips
  1511.  tst.w (a0)
  1512.  blt outofrcliplop
  1513.  
  1514.  bsr NEWsetrclip 
  1515.  bra intorcliplop
  1516.  
  1517. outofrcliplop:
  1518.  
  1519.  move.l ThisRoomToDraw,a0
  1520.  move.w leftclip,d0
  1521.  cmp.w #95,d0
  1522.  bge dontbothercantseeit
  1523.  move.w rightclip,d1
  1524.  blt dontbothercantseeit
  1525.  cmp.w d1,d0
  1526.  bge dontbothercantseeit
  1527.  
  1528.  bsr dothisroom
  1529.  
  1530. dontbothercantseeit:
  1531. pastemp:
  1532.  
  1533.  move.l (a7)+,a1
  1534.  move.l ThisRoomToDraw,a0
  1535.  move.w (a0),d7
  1536.  adda.w #8,a1
  1537.  bra finditit
  1538.  
  1539. nomoretodoatall:
  1540.  
  1541.  move.l (a7)+,a0
  1542.  
  1543.  bra subroomloop
  1544.  
  1545. jumpoutofrooms:
  1546.  
  1547.  rts
  1548.  
  1549. TempBuffer: ds.l 100 
  1550.  
  1551. ClipTable: ds.l 30
  1552. EndOfClipPt: dc.l 0
  1553.  
  1554. dothisroom
  1555.  
  1556.  move.w (a0)+,d0
  1557.  move.w d0,currzone
  1558.  move.l ZoneAdds,a1
  1559.  move.l (a1,d0.w*4),a1
  1560.  add.l #LEVELDATA,a1
  1561.  move.w 10(a1),ZoneBright
  1562.  
  1563. polyloop:
  1564.  move.w (a0)+,d0
  1565.  blt jumpoutofloop
  1566.  beq itsawall
  1567.  cmp.w #3,d0
  1568.  beq itsasetclip
  1569.  blt itsafloor
  1570.  cmp.w #4,d0
  1571.  beq itsanobject
  1572.  cmp.w #5,d0
  1573.  beq.s itsanarc
  1574.  cmp.w #6,d0
  1575.  beq itsalightbeam
  1576.  cmp.w #7,d0
  1577.  beq.s itswater
  1578.  cmp.w #9,d0
  1579.  ble itsachunkyfloor
  1580.  cmp.w #11,d0
  1581.  ble.s itsabumpyfloor
  1582.  cmp.w #12,d0
  1583.  beq.s itsbackdrop
  1584.  cmp.w #13,d0
  1585.  beq.s itsaseewall
  1586.  
  1587.  bra polyloop
  1588.  
  1589. itsaseewall:
  1590.  st seethru
  1591.  move.l #stripbufferthru,a1
  1592.  jsr itsawalldraw
  1593.  bra polyloop
  1594.  
  1595. itsbackdrop:
  1596.  jsr putinbackdrop
  1597.  bra polyloop
  1598.  
  1599. itswater:
  1600.  move.w #1,d0
  1601.  move.l #FloorLine,LineToUse
  1602.  st usewater
  1603.  clr.b usebumps
  1604.  jsr itsafloordraw
  1605.  bra polyloop
  1606.  
  1607. itsanarc:
  1608.  jsr CurveDraw
  1609.  bra polyloop
  1610. itsanobject:
  1611.  jsr ObjDraw
  1612.  bra polyloop
  1613. itsalightbeam:
  1614.  jsr LightDraw
  1615.  bra polyloop
  1616.  
  1617. itsabumpyfloor:
  1618.  sub.w #9,d0
  1619.  st usebumps
  1620.  st smoothbumps
  1621.  clr.b usewater
  1622.  move.l #BumpLine,LineToUse
  1623.  jsr itsafloordraw
  1624.  bra polyloop
  1625.  
  1626. itsachunkyfloor:
  1627.  subq.w #7,d0
  1628.  st usebumps
  1629.  sub.w #12,topclip
  1630. ; add.w #10,botclip
  1631.  clr.b smoothbumps
  1632.  clr.b usewater
  1633.  move.l #BumpLine,LineToUse
  1634.  jsr itsafloordraw
  1635.  add.w #12,topclip
  1636. ; sub.w #10,botclip
  1637.  bra polyloop 
  1638.  
  1639. prot9: dc.w 0
  1640.  
  1641. itsafloor:
  1642.  
  1643.  move.l #FloorLine,LineToUse
  1644. * 1,2 = floor/roof
  1645.  clr.b usewater
  1646.  clr.b usebumps
  1647.  jsr itsafloordraw
  1648.  bra polyloop
  1649. itsasetclip:
  1650.  bra polyloop
  1651. itsawall:
  1652.  clr.b seethru
  1653.  move.l #stripbuffer,a1
  1654.  jsr itsawalldraw
  1655.  bra polyloop
  1656.  
  1657. jumpoutofloop:
  1658.  rts
  1659.  
  1660. ThisRoomToDraw: dc.l 0
  1661.  
  1662.  include "ab3:source/OrderZones"
  1663.  
  1664. ReadMouse:
  1665.  clr.l d0
  1666.  clr.l d1
  1667.  move.w $a(a6),d0
  1668.  lsr.w #8,d0
  1669.  ext.l d0
  1670.  move.w d0,d3
  1671.  move.w oldy,d2
  1672.  sub.w d2,d0
  1673.  
  1674.  cmp.w #127,d0
  1675.  blt nonegy
  1676.  move.w #255,d1
  1677.  sub.w d0,d1
  1678.  move.w d1,d0
  1679.  neg.w d0
  1680. nonegy:
  1681.  
  1682.  cmp.w #-127,d0
  1683.  bge nonegy2
  1684.  move.w #255,d1
  1685.  add.w d0,d1
  1686.  move.w d1,d0
  1687. nonegy2:
  1688.  
  1689.  add.b d0,d2
  1690.  add.w d0,oldy2
  1691.  move.w d2,oldy
  1692.  move.w d2,d0
  1693.  
  1694.  move.w oldy2,d0
  1695.  move.w d0,ymouse
  1696.  
  1697.  clr.l d0
  1698.  clr.l d1
  1699.  move.w $a(a6),d0
  1700.  ext.w d0
  1701.  ext.l d0
  1702.  move.w d0,d3
  1703.  move.w oldmx,d2
  1704.  sub.w d2,d0
  1705.  
  1706.  cmp.w #127,d0
  1707.  blt nonegx
  1708.  move.w #255,d1
  1709.  sub.w d0,d1
  1710.  move.w d1,d0
  1711.  neg.w d0
  1712. nonegx:
  1713.  
  1714.  cmp.w #-127,d0
  1715.  bge nonegx2
  1716.  move.w #255,d1
  1717.  add.w d0,d1
  1718.  move.w d1,d0
  1719. nonegx2:
  1720.  
  1721.  add.b d0,d2
  1722.  move.w d0,d1
  1723.  move.w d2,oldmx
  1724.  
  1725.  
  1726.  move.w #$0,$dff034
  1727.  btst #2,$dff016
  1728.  beq.s noturn
  1729.  
  1730.  add.w d0,oldx2
  1731.  move.w oldx2,d0
  1732.  and.w #2047,d0
  1733.  move.w d0,oldx2
  1734.  
  1735.  asl.w #2,d0
  1736.  sub.w prevx,d0
  1737.  add.w d0,prevx
  1738.  add.w d0,PLR1s_angpos
  1739.  move.w #0,lrs
  1740.  rts
  1741.  
  1742. noturn:
  1743.  
  1744. ; got to move lr instead. 
  1745.  
  1746. ; d1 = speed moved l/r
  1747.  
  1748.  move.w d1,lrs
  1749.  
  1750.  rts
  1751.  
  1752. lrs: dc.w 0
  1753. prevx: dc.w 0
  1754.  
  1755. mang: dc.w 0
  1756. oldymouse: dc.w 0
  1757. xmouse: dc.w 0
  1758. ymouse: dc.w 0
  1759. oldx2: dc.w 0
  1760. oldmx: dc.w 0
  1761. oldy: dc.w 0
  1762. oldy2: dc.w 0
  1763.  
  1764. RotateLevelPts:
  1765.  
  1766.  move.w sinval,d6
  1767.  swap d6
  1768.  move.w cosval,d6
  1769.  
  1770.  move.l PointsToRotatePtr,a0
  1771.  move.l Points,a3
  1772.  move.l #Rotated,a1
  1773.  move.l #OnScreen,a2
  1774.  move.w xoff,d4
  1775.  move.w zoff,d5
  1776.  
  1777. ; move.w #$c40,$dff106
  1778. ; move.w #$f00,$dff180
  1779.  
  1780. pointrotlop:
  1781.  move.w (a0)+,d7
  1782.  blt.s outofpointrot
  1783.  
  1784.  move.w (a3,d7*4),d0
  1785.  sub.w d4,d0
  1786.  move.w d0,d2
  1787.  move.w 2(a3,d7*4),d1
  1788.  sub.w d5,d1
  1789.  muls d6,d2
  1790.  swap d6
  1791.  move.w d1,d3
  1792.  muls d6,d3
  1793.  sub.l d3,d2
  1794.  add.l d2,d2
  1795.  swap d2
  1796.  ext.l d2
  1797.  asl.l #7,d2
  1798.  add.l xwobble,d2
  1799.  move.l d2,(a1,d7*8)
  1800.  
  1801.  muls d6,d0
  1802.  swap d6
  1803.  muls d6,d1
  1804.  add.l d0,d1
  1805.  asl.l #2,d1
  1806.  swap d1
  1807.  move.l d1,4(a1,d7*8)
  1808.  
  1809.  tst.w d1
  1810.  bgt.s ptnotbehind
  1811.  tst.w d2
  1812.  bgt.s onrightsomewhere
  1813.  move.w #0,d2
  1814.  bra putin
  1815. onrightsomewhere:
  1816.  move.w #96,d2
  1817.  bra putin
  1818. ptnotbehind:
  1819.  
  1820.  divs d1,d2
  1821.  add.w #47,d2
  1822. putin:
  1823.  move.w d2,(a2,d7*2)
  1824.  
  1825.  bra pointrotlop
  1826. outofpointrot:
  1827.  
  1828. ; move.w #$c40,$dff106
  1829. ; move.w #$ff0,$dff180
  1830.  
  1831.  rts
  1832.  
  1833. RotateObjectPts:
  1834.  
  1835.  move.w sinval,d5
  1836.  move.w cosval,d6
  1837.  
  1838.  move.l ObjectPoints,a0
  1839.  move.w NumObjectPoints,d7
  1840.  move.l #ObjRotated,a1
  1841.  move.l #ObsInLine,a2
  1842. objpointrotlop:
  1843.  
  1844.  move.w (a0),d0
  1845.  sub.w xoff,d0
  1846.  move.w 4(a0),d1
  1847.  addq #8,a0
  1848.  sub.w zoff,d1
  1849.  move.w d0,d2
  1850.  muls d6,d2
  1851.  move.w d1,d3
  1852.  muls d5,d3
  1853.  sub.l d3,d2
  1854.  add.l d2,d2
  1855.  swap d2
  1856.  move.w d2,(a1)+
  1857.  
  1858.  muls d5,d0
  1859.  muls d6,d1
  1860.  add.l d0,d1
  1861.  asl.l #2,d1
  1862.  swap d1
  1863.  moveq #0,d3
  1864.  
  1865.  move.w d1,(a1)+
  1866.  ext.l d2
  1867.  asl.l #7,d2
  1868.  add.l xwobble,d2
  1869.  move.l d2,(a1)+
  1870.  sub.l xwobble,d2
  1871.  tst.w d1
  1872.  ble.s notinline
  1873.  
  1874.  cmp.l #-60*128,d2
  1875.  blt.s notinline
  1876.  cmp.l #60*128,d2
  1877.  sle d3
  1878. notinline
  1879.  move.b d3,(a2)+
  1880.  
  1881.  dbra d7,objpointrotlop
  1882.  
  1883.  rts
  1884.  
  1885. LightDraw:
  1886.  
  1887.  move.w (a0)+,d0
  1888.  move.w (a0)+,d1
  1889.  move.l #Rotated,a1
  1890.  move.w 6(a1,d0.w*8),d2
  1891.  ble.s oneendbehind
  1892.  move.w 6(a1,d1.w*8),d3
  1893.  bgt.s bothendsinfront
  1894.  
  1895. oneendbehind:
  1896.  rts
  1897. bothendsinfront:
  1898.  
  1899.  move.l #OnScreen,a2
  1900.  move.w (a2,d0.w*2),d0
  1901.  bge.s okleftend
  1902.  moveq #0,d0
  1903. okleftend:
  1904.  move.w (a2,d1.w*2),d1
  1905.  bgt.s somevis
  1906.  rts
  1907. somevis:
  1908.  cmp.w #95,d0
  1909.  ble.s somevis2
  1910.  rts
  1911. somevis2:
  1912.  cmp.w #95,d1
  1913.  ble.s okrightend
  1914.  move.w #95,d1
  1915. okrightend:
  1916.  
  1917.  sub.w d0,d1
  1918.  blt.s wrongbloodywayround
  1919.  move.l #brightentab,a4
  1920.  move.l #objintocop,a1
  1921.  lea (a1,d0.w*2),a1
  1922.  
  1923.  move.l frompt,a3
  1924.  move.w #104*4,d6
  1925.  move.w #79,d2
  1926. lacross:
  1927.  move.w d2,d3
  1928.  move.l a3,a2
  1929.  adda.w (a1)+,a2
  1930. ldown:
  1931.  add.w d6,a2
  1932.  move.w (a2),d7
  1933.  move.w (a4,d7.w*2),(a2)
  1934.  dbra d3,ldown
  1935.  dbra d1,lacross
  1936.  
  1937. wrongbloodywayround:
  1938.  
  1939.  rts
  1940.  
  1941. FaceToPlace: dc.w 0
  1942.  
  1943. Cheese:
  1944.  dc.w 4,15
  1945.  
  1946. FacesList:
  1947.  dc.w 0,4*4
  1948.  dc.w 1,2*4
  1949.  dc.w 0,2*4
  1950.  dc.w 2,2*4
  1951.  dc.w 0,2*4
  1952.  dc.w 1,3*4
  1953.  dc.w 0,2*4
  1954.  dc.w 2,3*4
  1955.  dc.w 0,5*4
  1956.  dc.w 1,2*4
  1957.  dc.w 0,2*4
  1958.  dc.w 2,2*4
  1959.  dc.w 0,2*4
  1960.  dc.w 1,2*4
  1961.  dc.w 0,2*4
  1962.  dc.w 2,3*4
  1963.  dc.w 0,1*4
  1964.  dc.w 1,3*4
  1965.  dc.w 0,1*4
  1966.  dc.w 2,3*4
  1967.  dc.w 0,1*4
  1968.  
  1969. EndOfFacesList:
  1970.  
  1971. FacesPtr:
  1972.  dc.l FacesList
  1973. FacesCounter:
  1974.  dc.w 0
  1975. Expression:
  1976.  dc.w 0
  1977.  
  1978. PlaceFace:
  1979.  
  1980.  move.w FacesCounter,d0
  1981.  subq #1,d0
  1982.  bgt.s NoNewFace
  1983.  
  1984.  move.l FacesPtr,a0
  1985.  
  1986.  move.w 2(a0),d0
  1987.  move.w (a0),Expression
  1988.  addq #4,a0
  1989.  cmp.l #EndOfFacesList,a0
  1990.  blt.s NotFirstFace
  1991.  
  1992.  move.l #FacesList,a0
  1993.  
  1994. NotFirstFace
  1995.  move.l a0,FacesPtr
  1996.  
  1997. NoNewFace:
  1998.  
  1999.  move.w d0,FacesCounter
  2000.  
  2001.  Move.w FaceToPlace,d0
  2002.  muls #5,d0
  2003.  add.w Expression,d0
  2004.  move.l #FacePlace+10,a0
  2005.  move.l #Faces,a1
  2006.  muls #(4*32*5),d0
  2007.  adda.w d0,a1
  2008.  move.w #4,d0
  2009.  move.w #24,d1
  2010.  
  2011.  move.w #4,d3
  2012. bitplaneloop:
  2013.  move.w #31,d2
  2014. PlaceFaceToPlaceInFacePlaceLoop:
  2015.  move.l (a1),(a0)
  2016.  adda.w d0,a1
  2017.  adda.w d1,a0
  2018.  dbra d2,PlaceFaceToPlaceInFacePlaceLoop
  2019.  dbra d3,bitplaneloop
  2020.  
  2021.  rts
  2022.  
  2023. Energy:
  2024.  dc.w 191
  2025. OldEnergy:
  2026.  dc.w 191
  2027. Ammo: dc.w 63
  2028. OldAmmo: dc.w 63
  2029.  
  2030. FullEnergy:
  2031.  move.w #127,Energy
  2032.  move.w #127,OldEnergy
  2033.  move.l #health,a0
  2034.  move.l #borders,a1
  2035.  add.l #25*8*2+6,a1
  2036.  lea 2592(a1),a2
  2037.  move.w #127,d0
  2038. PutInFull:
  2039.  move.b (a0)+,(a1)
  2040.  move.b (a0)+,8(a1)
  2041.  add.w #16,a1
  2042.  move.b (a0)+,(a2)
  2043.  move.b (a0)+,8(a2)
  2044.  add.w #16,a2
  2045.  dbra d0,PutInFull
  2046.  
  2047.  rts
  2048.  
  2049. EnergyBar:
  2050.  
  2051.  move.w Energy,d0
  2052.  cmp.w OldEnergy,d0
  2053.  bne.s gottochange
  2054.  
  2055. NoChange
  2056.  rts
  2057.  
  2058. gottochange:
  2059.   
  2060.  blt LessEnergy
  2061.  cmp.w #127,Energy
  2062.  blt.s NotMax
  2063.  move.w #127,Energy
  2064. NotMax:
  2065.  
  2066.  move.w Energy,d0
  2067.  move.w OldEnergy,d2
  2068.  sub.w d0,d2
  2069.  beq.s NoChange    
  2070.  neg.w d2
  2071.  
  2072.  move.w #127,d3
  2073.  sub.w d0,d3
  2074.  
  2075.  move.l #health,a0
  2076.  lea (a0,d3.w*4),a0
  2077.  move.l #borders+25*16+6,a1
  2078.  lsl.w #4,d3
  2079.  add.w d3,a1
  2080.  lea 2592(a1),a2
  2081.  
  2082. EnergyRise:
  2083.  move.b (a0)+,(a1)
  2084.  move.b (a0)+,8(a1)
  2085.  add.w #16,a1
  2086.  move.b (a0)+,(a2)
  2087.  move.b (a0)+,8(a2)
  2088.  add.w #16,a2
  2089.  subq #1,d2
  2090.  bgt.s EnergyRise
  2091.  
  2092.  move.w Energy,OldEnergy
  2093.  
  2094.  rts 
  2095.  
  2096. LessEnergy: 
  2097.  move.w OldEnergy,d2
  2098.  sub.w d0,d2
  2099.  
  2100.  move.w #127,d3
  2101.  sub.w OldEnergy,d3
  2102.  
  2103.  move.l #borders+25*16+6,a1
  2104.  asl.w #4,d3
  2105.  add.w d3,a1
  2106.  lea 2592(a1),a2
  2107.  
  2108. EnergyDrain:
  2109.  move.b #0,(a1)
  2110.  move.b #0,8(a1)
  2111.  move.b #0,(a2)
  2112.  move.b #0,8(a2)
  2113.  add.w #16,a1
  2114.  add.w #16,a2
  2115.  subq #1,d2
  2116.  bgt.s EnergyDrain
  2117.  
  2118.  move.w Energy,OldEnergy
  2119.  
  2120.  rts 
  2121.  
  2122. AmmoBar:
  2123.  
  2124.  move.w Ammo,d0
  2125.  cmp.w OldAmmo,d0
  2126.  bne.s .gottochange
  2127.  
  2128. .NoChange
  2129.  rts
  2130.  
  2131. .gottochange:
  2132.   
  2133.  blt LessAmmo
  2134.  cmp.w #63,Ammo
  2135.  blt.s .NotMax
  2136.  move.w #63,Ammo
  2137. .NotMax:
  2138.  
  2139.  move.w Ammo,d0
  2140.  move.w OldAmmo,d2
  2141.  sub.w d0,d2
  2142.  beq.s .NoChange
  2143.  neg.w d2
  2144.  
  2145.  move.w #63,d3
  2146.  sub.w d0,d3
  2147.  
  2148.  move.l #Ammunition,a0
  2149.  lea (a0,d3.w*8),a0
  2150.  move.l #borders+5184+25*16+1,a1
  2151.  lsl.w #5,d3
  2152.  add.w d3,a1
  2153.  lea 2592(a1),a2
  2154.  
  2155. AmmoRise:
  2156.  move.b (a0)+,(a1)
  2157.  move.b (a0)+,8(a1)
  2158.  add.w #16,a1
  2159.  move.b (a0)+,(a2)
  2160.  move.b (a0)+,8(a2)
  2161.  add.w #16,a2
  2162.  move.b (a0)+,(a1)
  2163.  move.b (a0)+,8(a1)
  2164.  add.w #16,a1
  2165.  move.b (a0)+,(a2)
  2166.  move.b (a0)+,8(a2)
  2167.  add.w #16,a2
  2168.  subq #1,d2
  2169.  bgt.s AmmoRise
  2170.  
  2171.  move.w Ammo,OldAmmo
  2172.  
  2173.  rts 
  2174.  
  2175.  
  2176. LessAmmo: 
  2177.  move.w OldAmmo,d2
  2178.  sub.w d0,d2
  2179.  
  2180.  move.w #63,d3
  2181.  sub.w OldAmmo,d3
  2182.  
  2183.  move.l #borders++5184+25*16+1,a1
  2184.  asl.w #5,d3
  2185.  add.w d3,a1
  2186.  lea 2592(a1),a2
  2187.  
  2188. AmmoDrain:
  2189.  move.b #0,(a1)
  2190.  move.b #0,8(a1)
  2191.  move.b #0,(a2)
  2192.  move.b #0,8(a2)
  2193.  add.w #16,a1
  2194.  add.w #16,a2
  2195.  move.b #0,(a1)
  2196.  move.b #0,8(a1)
  2197.  move.b #0,(a2)
  2198.  move.b #0,8(a2)
  2199.  add.w #16,a1
  2200.  add.w #16,a2
  2201.  subq #1,d2
  2202.  bgt.s AmmoDrain
  2203.  
  2204.  move.w Ammo,OldAmmo
  2205.  
  2206.  rts 
  2207.  
  2208. nulop:
  2209.  move.w #$0010,$dff000+intreq
  2210.  rte
  2211.  
  2212. doanything: dc.w 0
  2213.  
  2214. end:
  2215.  
  2216.  move.l drawpt,d0
  2217.  move.l olddrawpt,drawpt
  2218.  move.l d0,olddrawpt
  2219.  move.l d0,$dff084
  2220.  
  2221.  clr.b doanything
  2222.  cmp.b #'b',Prefsfile+3
  2223.  bne.s .noback
  2224.  jsr mt_end
  2225. .noback
  2226.  tst.w Energy
  2227.  bgt.s wevewon
  2228.  
  2229.  move.l #gameover,mt_data
  2230.  st UseAllChannels
  2231.  clr.b reachedend
  2232.  jsr mt_init
  2233. playgameover:
  2234.  move.l #$dff000,a6
  2235. waitfortop2:
  2236.  btst.b #0,intreqrl(a6)
  2237.  beq waitfortop2
  2238.  move.w #$1,intreq(a6)
  2239.  
  2240.  jsr mt_music
  2241.  
  2242.  tst.b reachedend
  2243.  beq.s playgameover
  2244.  
  2245.  bra wevelost
  2246. wevewon:
  2247.  move.l #welldone,mt_data
  2248.  st UseAllChannels
  2249.  clr.b reachedend
  2250.  jsr mt_init
  2251. playwelldone:
  2252.  move.l #$dff000,a6
  2253. waitfortop3:
  2254.  btst.b #0,intreqrl(a6)
  2255.  beq waitfortop3
  2256.  move.w #$1,intreq(a6)
  2257.  
  2258.  jsr mt_music
  2259.  
  2260.  tst.b reachedend
  2261.  beq.s playwelldone
  2262.  
  2263.  
  2264. wevelost:
  2265.  jmp closeeverything 
  2266.  
  2267. do32:
  2268.  move.w #31,d7
  2269.  move.w #$180,d1
  2270. across:
  2271.  move.w d1,(a1)+
  2272.  move.w d1,(a3)+
  2273.  move.w #0,(a1)+
  2274.  move.w #0,(a3)+
  2275.  add.w #2,d1
  2276.  dbra d7,across
  2277.  rts
  2278.  
  2279.  
  2280.  
  2281. *************************************
  2282. * Set left and right clip values
  2283. *************************************
  2284.  
  2285.  
  2286.  
  2287. NEWsetlclip:
  2288.  move.l #OnScreen,a1
  2289.  move.l #Rotated,a2
  2290.  
  2291.  move.w (a0),d0
  2292.  bge.s .notignoreleft
  2293.  
  2294. ; move.l #0,(a6)
  2295.  
  2296.  bra .leftnotoktoclip
  2297. .notignoreleft:
  2298.  
  2299.  move.w 6(a2,d0*8),d3    ; left z val
  2300.  bgt.s .leftclipinfront
  2301.  addq #4,a0
  2302.  rts
  2303.  
  2304.  tst.w 6(a2,d0*8)
  2305.  bgt.s .leftnotoktoclip
  2306. .ignoreboth:
  2307. ; move.l #0,(a6)
  2308. ; move.l #96*65536,4(a6)
  2309.  move.w #0,leftclip
  2310.  move.w #96,rightclip
  2311.  addq #8,a6
  2312.  addq #8,a0
  2313.  rts
  2314.  
  2315. .leftclipinfront:
  2316.  move.w (a1,d0*2),d1    ; left x on screen
  2317.  move.w 2(a0),d2
  2318.  move.w (a1,d2.w*2),d2
  2319.  cmp.w d1,d2
  2320.  bgt.s .leftnotoktoclip
  2321.  
  2322. ; move.w d1,(a6)
  2323. ; move.w d3,2(a6)
  2324.  cmp.w leftclip(pc),d1
  2325.  ble.s .leftnotoktoclip
  2326.  move.w d1,leftclip
  2327. .leftnotoktoclip:
  2328.  
  2329.  addq #4,a0
  2330.  
  2331.  rts
  2332.  
  2333. NEWsetrclip
  2334.  move.l #OnScreen,a1
  2335.  move.l #Rotated,a2
  2336.  move.w (a0),d0
  2337.  bge.s .notignoreright
  2338. ; move.w #96,4(a6)
  2339. ; move.w #0,6(a6)
  2340.  move.w #0,d4
  2341.  bra .rightnotoktoclip
  2342. .notignoreright:
  2343.  move.w 6(a2,d0*8),d4    ; right z val
  2344.  bgt.s .rightclipinfront
  2345. ; move.w #96,4(a6)
  2346. ; move.w #0,6(a6)
  2347.  bra.s .rightnotoktoclip
  2348.  
  2349. .rightclipinfront:
  2350.  move.w (a1,d0*2),d1    ; right x on screen
  2351.  move.w 2(a0),d2
  2352.  move.w (a1,d2.w*2),d2
  2353.  cmp.w d1,d2
  2354.  blt.s .rightnotoktoclip
  2355. ; move.w d1,4(a6)
  2356. ; move.w d4,6(a6)
  2357.  
  2358.  cmp.w rightclip(pc),d1
  2359.  bge.s .rightnotoktoclip
  2360.  addq #1,d1
  2361.  move.w d1,rightclip
  2362. .rightnotoktoclip:
  2363.  addq #8,a6
  2364.  addq #4,a0
  2365.  rts
  2366.  
  2367. FIRSTsetlrclip:
  2368.  move.l #OnScreen,a1
  2369.  move.l #Rotated,a2
  2370.  
  2371.  move.w (a0)+,d0
  2372.  bge.s .notignoreleft
  2373.  bra .leftnotoktoclip
  2374. .notignoreleft:
  2375.  
  2376.  move.w 6(a2,d0*8),d3    ; left z val
  2377.  bgt.s .leftclipinfront
  2378.  
  2379.  move.w (a0),d0
  2380.  blt.s .ignoreboth
  2381.  tst.w 6(a2,d0*8)
  2382.  bgt.s .leftnotoktoclip
  2383. .ignoreboth
  2384.  move.w #96,rightclip
  2385.  move.w #0,leftclip
  2386.  addq #2,a0
  2387.  rts
  2388.  
  2389. .leftclipinfront:
  2390.  move.w (a1,d0*2),d1    ; left x on screen
  2391.  cmp.w leftclip(pc),d1
  2392.  ble.s .leftnotoktoclip
  2393.  move.w d1,leftclip
  2394. .leftnotoktoclip:
  2395.  
  2396.  move.w (a0)+,d0
  2397.  bge.s .notignoreright
  2398.  move.w #0,d4
  2399.  bra .rightnotoktoclip
  2400. .notignoreright:
  2401.  move.w 6(a2,d0*8),d4    ; right z val
  2402.  ble.s .rightnotoktoclip
  2403.  
  2404. .rightclipinfront:
  2405.  move.w (a1,d0*2),d1    ; right x on screen
  2406.  cmp.w rightclip(pc),d1
  2407.  bge.s .rightnotoktoclip
  2408.  addq #1,d1
  2409.  move.w d1,rightclip
  2410. .rightnotoktoclip:
  2411.  
  2412. ; move.w leftclip,d0
  2413. ; move.w rightclip,d1
  2414. ; cmp.w d0,d1
  2415. ; bge.s .noswap
  2416. ; move.w #96,rightclip
  2417. ; move.w #0,leftclip
  2418. ;.noswap:
  2419.  
  2420.  rts
  2421.  
  2422.  
  2423. leftclip2: dc.w 0
  2424. rightclip2: dc.w 0
  2425. ZoneBright: dc.w 0
  2426.  
  2427. npolys: dc.w 0
  2428.  
  2429. PLR1_fire: dc.b 0
  2430. PLR2_fire: dc.b 0
  2431.  
  2432. turnleftright:
  2433.  
  2434.  move.w PLR2_angspd,d1
  2435.  move.w PLR2_angpos,d0
  2436.  
  2437.  move.w #120,d7
  2438.  muls TempFrames,d7
  2439.  
  2440.  move.w d1,d2
  2441.  neg.w d2
  2442.  cmp.w d7,d2
  2443.  ble.s okslow
  2444.  move.w d7,d2
  2445. okslow
  2446.  neg.w d7
  2447.  cmp.w d7,d2
  2448.  bge.s okslo
  2449.  move.w d7,d2
  2450. okslo:
  2451.  
  2452.  asr.w #1,d7
  2453.  
  2454.  btst #1,$d(a6)
  2455.  sne d3
  2456.  beq.s notleft
  2457.  move.w d7,d2
  2458.  neg.w d2
  2459. ; tst.w d1
  2460. ; bge.s notleft
  2461. ; moveq #0,d1
  2462. notleft
  2463.  
  2464.  btst #1,$c(a6)
  2465.  sne d4
  2466.  beq.s notright
  2467.  move.w d7,d2
  2468. ; tst.w d1
  2469. ; ble.s notright
  2470. ; moveq #0,d1
  2471. notright
  2472.  
  2473.  move.w #0,PLR2_ForwardSpd
  2474.  
  2475.  btst #0,$dff00c
  2476.  sne d5
  2477.  eor.b d4,d5
  2478.  beq.s notup
  2479.  move.w TempFrames,d7
  2480.  neg.w d7
  2481.  asl.w #2,d7
  2482.  move.w d7,PLR2_ForwardSpd
  2483. notup:
  2484.  
  2485.  btst #0,$dff00d
  2486.  sne d5
  2487.  eor.b d3,d5
  2488.  beq.s notdown
  2489.  move.w TempFrames,d7
  2490.  asl.w #2,d7
  2491.  move.w d7,PLR2_ForwardSpd
  2492. notdown:
  2493.  
  2494.  add.w d2,d1
  2495.  cmp.w #-360,d1
  2496.  bge.s okspdlft
  2497.  move.w #-360,d1
  2498. okspdlft:
  2499.  cmp.w #360,d1
  2500.  ble.s okspdrgt
  2501.  move.w #360,d1
  2502. okspdrgt:
  2503.  
  2504.  move.w d1,PLR2_angspd
  2505.  add.w d1,d0
  2506.  and.w #8191,d0
  2507.  move.w d0,PLR2_angpos
  2508.  rts
  2509.  
  2510. *****************************************************
  2511.  
  2512.  include "ab3:source/ObjectMove"
  2513.  
  2514. pastdata:
  2515. ***********************************
  2516. * This routine animates brightnesses.
  2517.  
  2518.  
  2519. liftpt: dc.l liftanimtab
  2520.  
  2521. brightpt:
  2522.  dc.l brightanimtab
  2523.  
  2524. liftanim:
  2525.  rts
  2526.  
  2527. ******************************
  2528.  include "ab3:source/Anims"
  2529. ******************************
  2530.  
  2531. rotanimpt: dc.w 0
  2532. xradd: dc.w 5
  2533. yradd: dc.w 8
  2534. xrpos: dc.w 320
  2535. yrpos: dc.w 320
  2536.  
  2537. rotanim:
  2538.  rts
  2539.  
  2540. option:
  2541.  dc.l 0,0
  2542.  
  2543. ********** WALL STUFF *******************************
  2544.  
  2545.  include "AB3:source/wallroutine3.chipmem"
  2546.  
  2547. *****************************************************
  2548.  
  2549. ******************************************
  2550. * floor polygon
  2551.  
  2552. numsidestd: dc.w 0
  2553. bottomline: dc.w 0
  2554.  
  2555. NewCornerBuff:
  2556.  ds.l 100
  2557.  
  2558. itsafloordraw:
  2559.  
  2560. * If D0 =1 then its a floor otherwise (=2) it's
  2561. * a roof.
  2562.  
  2563.  move.w #0,above
  2564.  move.w (a0)+,d6    ; ypos of poly
  2565.  
  2566.  move.w leftclip(pc),d7
  2567.  cmp.w rightclip(pc),d7
  2568.  bge.s dontdrawreturn
  2569.  
  2570.  move.w botclip,d7
  2571.  sub.w #40,d7
  2572.  ble.s dontdrawreturn
  2573.  sub.w flooryoff,d6
  2574.  bgt.s below
  2575.  blt.s aboveplayer
  2576. dontdrawreturn:
  2577.  move.w (a0)+,d6    ; sides-1
  2578.  add.w d6,d6
  2579.  add.w d6,a0
  2580.  add.w #4+6,a0
  2581.  rts
  2582. aboveplayer:
  2583.  cmp.w #2,d0
  2584.  bne.s dontdrawreturn
  2585.  move.w #40,d7
  2586.  sub.w topclip,d7 
  2587.  blt.s dontdrawreturn
  2588.  move.w #1,d0
  2589.  move.w d0,above
  2590.  neg.w d6
  2591. below:
  2592.  cmp.w #1,d0
  2593.  bne.s dontdrawreturn
  2594.  move.w d6,distaddr
  2595.  muls #64,d6
  2596.  move.l d6,ypos
  2597.  divs d7,d6        ; zpos of bottom
  2598.             ; visible line
  2599.  move.w d6,minz
  2600.  move.w d7,bottomline
  2601.  
  2602. ; Go round each point finding out
  2603. ; if it should be visible or not.
  2604.  
  2605.  move.l a0,-(a7)
  2606.  
  2607.  move.w (a0)+,d7    ; number of sides
  2608.  move.l #Rotated,a1
  2609.  move.l #OnScreen,a2
  2610.  move.l #NewCornerBuff,a3
  2611.  moveq #0,d4
  2612.  moveq #0,d5
  2613.  moveq #0,d6
  2614.  clr.b anyclipping
  2615.  
  2616. cornerprocessloop:
  2617.  
  2618.  move.w (a0)+,d0
  2619.  move.w 6(a1,d0.w*8),d1
  2620.  ble  .canttell
  2621.  
  2622.  move.w (a2,d0.w*2),d3
  2623.  cmp.w leftclip,d3
  2624.  bgt.s .nol
  2625.  st d4
  2626.  st anyclipping
  2627.  bra.s .nos
  2628. .nol:
  2629.  cmp.w rightclip,d3
  2630.  blt.s .nor
  2631.  st d6
  2632.  st anyclipping
  2633.  bra.s .nos
  2634. .nor:
  2635.  st d5
  2636. .nos:
  2637.  bra .cantell
  2638.  
  2639. .canttell:
  2640.  st d5
  2641.  st anyclipping
  2642.  
  2643. .cantell:
  2644.  
  2645.  
  2646.  dbra d7,cornerprocessloop
  2647.  
  2648.  move.l (a7)+,a0
  2649.  tst.b d5
  2650.  bne.s somefloortodraw
  2651.  eor.b d4,d6
  2652.  bne dontdrawreturn
  2653.  
  2654. somefloortodraw:
  2655.  
  2656.  move.w #80,top
  2657.  move.w #-1,bottom
  2658.  move.w #0,drawit
  2659.  move.l #Rotated,a1
  2660.  move.l #OnScreen,a2
  2661.  move.w (a0)+,d7    ; no of sides
  2662. sideloop:
  2663.  move.w minz,d6
  2664.  move.w (a0)+,d1
  2665.  move.w (a0),d3
  2666.  move.w 6(a1,d1*8),d4    ;first z
  2667.  cmp.w d6,d4
  2668.  bgt firstinfront
  2669.  move.w 6(a1,d3*8),d5    ; sec z
  2670.  cmp.w d6,d5
  2671.  ble bothbehind
  2672. ** line must be on left and partially behind.
  2673.  sub.w d5,d4
  2674.  move.l (a1,d1*8),d0
  2675.  sub.l (a1,d3*8),d0
  2676.  asr.l #7,d0
  2677.  sub.w d5,d6
  2678.  muls d6,d0    ; new x coord
  2679.  divs d4,d0
  2680.  ext.l d0
  2681.  asl.l #7,d0
  2682.  
  2683.  add.l (a1,d3*8),d0
  2684.  move.w minz,d4
  2685.  move.w (a2,d3*2),d2
  2686.  divs d4,d0
  2687.  add.w #47,d0
  2688.  move.l ypos,d3
  2689.  divs d5,d3
  2690.  move.w bottomline,d1 
  2691.  bra lineclipped
  2692.  
  2693. firstinfront:
  2694.  move.w 6(a1,d3*8),d5    ; sec z
  2695.  cmp.w d6,d5
  2696.  bgt bothinfront
  2697. ** line must be on right and partially behind.
  2698.  sub.w d4,d5    ; dz
  2699.  move.l (a1,d3*8),d2
  2700.  sub.l (a1,d1*8),d2    ; dx
  2701.  sub.w d4,d6
  2702.  asr.l #7,d2
  2703.  muls d6,d2    ; new x coord
  2704.  divs d5,d2
  2705.  ext.l d2
  2706.  asl.l #7,d2
  2707.  add.l (a1,d1*8),d2
  2708.  move.w minz,d5
  2709.  move.w (a2,d1*2),d0
  2710.  divs d5,d2
  2711.  add.w #47,d2
  2712.  move.l ypos,d1
  2713.  divs d4,d1
  2714.  move.w bottomline,d3 
  2715.  bra lineclipped
  2716.  
  2717. bothinfront:
  2718.  
  2719. * Also, usefully enough, both are on-screen
  2720. * so no bottom clipping is needed.
  2721.  
  2722.  move.w (a2,d1*2),d0    ; first x
  2723.  move.w (a2,d3*2),d2    ; second x
  2724.  move.l ypos,d1
  2725.  move.l d1,d3
  2726.  divs d4,d1        ; first y
  2727.  divs d5,d3        ; second y
  2728. lineclipped:
  2729.  move.l #rightsidetab,a3
  2730.  cmp.w d1,d3
  2731.  beq lineflat
  2732.  st drawit
  2733.  bgt lineonright
  2734.  move.l #leftsidetab,a3
  2735.  exg d1,d3
  2736.  exg d0,d2
  2737.  
  2738.  lea (a3,d1*2),a3
  2739.  
  2740.  cmp.w top(pc),d1
  2741.  bge.s .nonewtop
  2742.  move.w d1,top
  2743. .nonewtop:
  2744.  cmp.w bottom(pc),d3
  2745.  ble.s .nonewbot
  2746.  move.w d3,bottom
  2747. .nonewbot:
  2748.  
  2749.  sub.w d1,d3    ; dy
  2750.  sub.w d0,d2    ; dx
  2751.  
  2752.  blt .linegoingleft
  2753.  sub.w #1,d0
  2754.  
  2755.  ext.l d2
  2756.  divs d3,d2
  2757.  move.w d2,d6
  2758.  swap d2
  2759.  
  2760. ; moveq #0,d6
  2761. ; sub.w d3,d2
  2762. ; blt.s .noco
  2763. ;.makeco
  2764. ; addq #1,d6
  2765. ; sub.w d3,d2
  2766. ; bge.s .makeco
  2767. ;.noco
  2768. ; add.w d3,d2
  2769.  
  2770.  move.w d3,d4
  2771.  move.w d3,d5
  2772.  subq #1,d5
  2773.  move.w d6,d1
  2774.  addq #1,d1
  2775.  
  2776. .pixlopright:
  2777.  move.w d0,(a3)+
  2778.  sub.w d2,d4
  2779.  bge.s .nobigstep
  2780.  add.w d1,d0
  2781.  add.w d3,d4
  2782.  dbra d5,.pixlopright
  2783.  bra lineflat
  2784. .nobigstep
  2785.  add.w d6,d0
  2786.  dbra d5,.pixlopright
  2787.  bra lineflat
  2788.  
  2789. .linegoingleft:
  2790.  
  2791.  sub.w #1,d0
  2792.  
  2793.  neg.w d2
  2794.  
  2795.  ext.l d2
  2796.  divs d3,d2
  2797.  move.w d2,d6
  2798.  swap d2
  2799.  
  2800.  
  2801. ; moveq #0,d6
  2802. ; sub.w d3,d2
  2803. ; blt.s .nocol
  2804. ;.makecol
  2805. ; addq #1,d6
  2806. ; sub.w d3,d2
  2807. ; bge.s .makecol
  2808. ;.nocol
  2809. ; add.w d3,d2
  2810.  
  2811.  
  2812.  
  2813.  move.w d3,d4
  2814.  move.w d3,d5
  2815.  subq #1,d5
  2816.  
  2817.  move.w d6,d1
  2818.  addq #1,d1
  2819.  
  2820. .pixlopleft:
  2821.  sub.w d2,d4
  2822.  bge.s .nobigstepl
  2823.  sub.w d1,d0
  2824.  add.w d3,d4
  2825.  move.w d0,(a3)+
  2826.  dbra d5,.pixlopleft
  2827.  bra lineflat
  2828.  
  2829. .nobigstepl
  2830.  sub.w d6,d0
  2831.  move.w d0,(a3)+
  2832.  dbra d5,.pixlopleft
  2833.  bra lineflat
  2834.  
  2835. lineonright:
  2836.  
  2837.  lea (a3,d1*2),a3
  2838.  
  2839.  cmp.w top(pc),d1
  2840.  bge.s .nonewtop
  2841.  move.w d1,top
  2842. .nonewtop:
  2843.  cmp.w bottom(pc),d3
  2844.  ble.s .nonewbot
  2845.  move.w d3,bottom
  2846. .nonewbot:
  2847.  
  2848.  sub.w d1,d3    ; dy
  2849.  sub.w d0,d2    ; dx
  2850.  blt .linegoingleft
  2851. ; addq #1,d0
  2852.  ext.l d2
  2853.  divs d3,d2
  2854.  move.w d2,d6
  2855.  swap d2
  2856.  
  2857. ; moveq #0,d6
  2858. ; sub.w d3,d2
  2859. ; blt.s .noco
  2860. ;.makeco
  2861. ; addq #1,d6
  2862. ; sub.w d3,d2
  2863. ; bge.s .makeco
  2864. ;.noco
  2865. ; add.w d3,d2
  2866.  
  2867.  move.w d3,d4
  2868.  move.w d3,d5
  2869.  subq #1,d5
  2870.  move.w d6,d1
  2871.  addq #1,d1
  2872.  
  2873. .pixlopright:
  2874.  sub.w d2,d4
  2875.  bge.s .nobigstep
  2876.  add.w d1,d0
  2877.  add.w d3,d4
  2878.  move.w d0,(a3)+
  2879.  dbra d5,.pixlopright
  2880.  bra lineflat
  2881.  
  2882. .nobigstep
  2883.  add.w d6,d0
  2884.  move.w d0,(a3)+
  2885.  dbra d5,.pixlopright
  2886.  bra lineflat
  2887.  
  2888. .linegoingleft:
  2889. ; addq #1,d0
  2890.  neg.w d2
  2891.  
  2892.  ext.l d2
  2893.  divs d3,d2
  2894.  move.w d2,d6
  2895.  swap d2
  2896.  
  2897.  
  2898. ; moveq #0,d6
  2899. ; sub.w d3,d2
  2900. ; blt.s .nocol
  2901. ;.makecol
  2902. ; addq #1,d6
  2903. ; sub.w d3,d2
  2904. ; bge.s .makecol
  2905. ;.nocol
  2906. ; add.w d3,d2
  2907.  
  2908.  move.w d3,d4
  2909.  move.w d3,d5
  2910.  subq #1,d5
  2911.  move.w d6,d1
  2912.  addq #1,d1
  2913.  
  2914. .pixlopleft:
  2915.  move.w d0,(a3)+
  2916.  sub.w d2,d4
  2917.  bge.s .nobigstepl
  2918.  sub.w d1,d0
  2919.  add.w d3,d4
  2920.  dbra d5,.pixlopleft
  2921.  bra lineflat
  2922.  
  2923. .nobigstepl
  2924.  sub.w d6,d0
  2925.  dbra d5,.pixlopleft
  2926.  
  2927. lineflat:
  2928.  
  2929. bothbehind:
  2930.  dbra d7,sideloop
  2931.  
  2932. pastsides:
  2933.  
  2934.  
  2935.  addq #2,a0
  2936.  
  2937.  move.w #104*4,linedir
  2938.  move.l frompt,a6
  2939.  add.l #104*4*41,a6
  2940.  move.w (a0)+,scaleval
  2941.  move.w (a0)+,whichtile
  2942.  move.w (a0)+,d6
  2943.  add.w ZoneBright,d6
  2944.  move.w d6,lighttype
  2945.  move.w above(pc),d6
  2946.  beq groundfloor
  2947. * on ceiling:
  2948.  move.w #-104*4,linedir
  2949.  suba.w #104*4,a6
  2950. groundfloor:
  2951.  
  2952.  move.w xoff,d6
  2953.  move.w zoff,d7
  2954.  add.w xwobxoff,d7
  2955.  add.w xwobzoff,d6
  2956.  move.w scaleval(pc),d3
  2957.  beq.s .samescale
  2958.  bgt.s .scaledown
  2959.  neg.w d3
  2960.  asr.l d3,d7
  2961.  asr.l d3,d6
  2962.  bra.s .samescale
  2963. .scaledown:
  2964.  asl.l d3,d6
  2965.  asl.l d3,d7
  2966. .samescale
  2967.  asl.w #8,d7
  2968.  move.w d6,sxoff
  2969.  move.w d7,szoff
  2970.  bra pastscale 
  2971.  
  2972.  asr.l #3,d1
  2973.  asr.l #3,d2
  2974.  asr.l #2,d1
  2975.  asr.l #2,d2
  2976.  asr.l #1,d1
  2977.  asr.l #1,d2
  2978. scaleprogfrom
  2979.  nop
  2980.  nop
  2981.  asl.l #1,d1
  2982.  asl.l #1,d2
  2983.  asl.l #2,d1
  2984.  asl.l #2,d2
  2985.  asl.l #3,d1
  2986.  asl.l #3,d2
  2987.  
  2988. top: dc.w 0
  2989. bottom: dc.w 0
  2990. ypos: dc.l 0
  2991. nfloors: dc.w 0
  2992. lighttype: dc.w 0
  2993. above: dc.w 0 
  2994. linedir: dc.w 0
  2995. distaddr: dc.w 0
  2996.  
  2997. minz: dc.w 0
  2998. leftsidetab:
  2999.  ds.w 80
  3000. rightsidetab:
  3001.  ds.w 80
  3002. leftsideclip:
  3003.  ds.w 80
  3004. rightsideclip:
  3005.  ds.w 80
  3006.  
  3007. movespd: dc.w 0
  3008. largespd: dc.l 0
  3009.  
  3010. pastscale:
  3011.  
  3012.  tst.b drawit(pc)
  3013.  beq dontdrawfloor
  3014.  
  3015.  move.l a0,-(a7)
  3016.  
  3017.  move.l #leftsidetab,a4
  3018.  move.w top(pc),d1
  3019.  move.w bottom(pc),d7
  3020.  tst.w above
  3021.  beq.s clipfloor
  3022.  
  3023.  move.w #40,d3
  3024.  move.w d3,d4
  3025.  sub.w topclip,d3
  3026.  sub.w botclip,d4
  3027.  cmp.w d3,d1
  3028.  bge predontdrawfloor
  3029.  cmp.w d4,d7
  3030.  blt predontdrawfloor
  3031.  cmp.w d4,d1
  3032.  bge.s .nocliptoproof
  3033.  move.w d4,d1
  3034. .nocliptoproof
  3035.  cmp.w d3,d7
  3036.  blt doneclip
  3037.  move.w d3,d7
  3038.  bra doneclip
  3039.  
  3040. clipfloor:
  3041.  move.w botclip,d4
  3042.  sub.w #40,d4
  3043.  cmp.w d4,d1
  3044.  bge predontdrawfloor
  3045.  move.w topclip,d3
  3046.  sub.w #40,d3
  3047.  cmp.w d3,d1
  3048.  bge.s .nocliptopfloor
  3049.  move.w d3,d1
  3050. .nocliptopfloor 
  3051.  cmp.w d3,d7
  3052.  ble predontdrawfloor
  3053.  cmp.w d4,d7
  3054.  blt.s .noclipbotfloor
  3055.  move.w d4,d7
  3056. .noclipbotfloor:
  3057.  
  3058. doneclip:
  3059.  
  3060.  lea (a4,d1*2),a4
  3061. ; move.l #dists,a2
  3062.  move.w distaddr,d0
  3063.  muls #64,d0
  3064.  move.l d0,a2
  3065. ; muls #25,d0
  3066. ; adda.w d0,a2
  3067. ; lea (a2,d1*2),a2
  3068.  sub.w d1,d7
  3069.  ble predontdrawfloor 
  3070.  move.w d1,d0
  3071.  bne.s .notzero
  3072.  moveq #1,d0
  3073. .notzero
  3074.  muls linedir,d1
  3075.  add.l d1,a6
  3076.  move.l #floorscalecols,a1
  3077.  move.l LineToUse,a5
  3078.  
  3079.  tst.b anyclipping
  3080.  beq dofloornoclip
  3081.  
  3082. dofloor:
  3083. ; move.w (a2)+,d0
  3084.  move.w leftclip(pc),d3
  3085.  move.w rightclip(pc),d4
  3086.  move.w rightsidetab-leftsidetab(a4),d2
  3087.  addq #1,d2
  3088.  cmp.w d3,d2
  3089.  ble.s nodrawline
  3090.  cmp.w d4,d2
  3091.  ble.s noclipright
  3092.  move.w d4,d2
  3093. noclipright:
  3094.  move.w (a4),d1
  3095.  cmp.w d4,d1
  3096.  bge.s nodrawline
  3097.  cmp.w d3,d1
  3098.  bge.s noclipleft
  3099.  move.w d3,d1
  3100. noclipleft:
  3101.  cmp.w d1,d2
  3102.  ble.s nodrawline
  3103.  
  3104.  move.w d1,leftedge
  3105.  move.w d2,rightedge
  3106.  
  3107.  move.l a6,a3
  3108.  movem.l d0/d7/a2/a4/a5/a6,-(a7)
  3109.  move.l a2,d7
  3110.  divs d0,d7
  3111.  move.w d7,d0
  3112.  jsr (a5)
  3113.  movem.l (a7)+,d0/d7/a2/a4/a5/a6
  3114. nodrawline
  3115.  adda.w linedir(pc),a6
  3116.  addq #2,a4
  3117.  addq #1,d0
  3118.  subq #1,d7
  3119.  bgt dofloor
  3120.  
  3121. predontdrawfloor
  3122.  move.l (a7)+,a0
  3123.  
  3124. dontdrawfloor:
  3125.  
  3126.  CACHE_FREEZE_OFF d2
  3127.  rts
  3128.  
  3129. anyclipping: dc.w 0
  3130.  
  3131. dofloornoclip:
  3132. ; move.w (a2)+,d0
  3133.  move.w rightsidetab-leftsidetab(a4),d2
  3134.  addq #1,d2
  3135.  move.w (a4)+,leftedge
  3136.  move.w d2,rightedge
  3137.  
  3138.  move.l a6,a3
  3139.  movem.l d0/d7/a2/a4/a5/a6,-(a7)
  3140.  move.l a2,d7
  3141.  divs d0,d7
  3142.  move.w d7,d0
  3143.  jsr (a5)
  3144.  movem.l (a7)+,d0/d7/a2/a4/a5/a6
  3145.  adda.w linedir(pc),a6
  3146.  addq #1,d0
  3147.  subq #1,d7
  3148.  bgt dofloornoclip
  3149.  
  3150.  bra predontdrawfloor
  3151.  
  3152.  
  3153. dists:
  3154. ; incbin "floordists"
  3155. drawit: dc.w 0
  3156.  
  3157. LineToUse: dc.l 0
  3158.  
  3159. ***************************
  3160. * Right then, time for the floor
  3161. * routine...
  3162. * For test purposes, give it
  3163. * a3 = point to screen
  3164. * d0= z distance away
  3165. * and sinval+cosval must be set up.
  3166. ***************************
  3167.  
  3168. leftedge: dc.w 0
  3169. rightedge: dc.w 0
  3170.  
  3171. rndpt: dc.l rndtab
  3172.  
  3173. WaterFloorLine:
  3174.  
  3175.  CACHE_OFF d2
  3176.  
  3177.  move.l #doacrossline,a1
  3178.  move.w leftedge(pc),d1
  3179.  move.w rightedge(pc),d2
  3180.  sub.w d1,d2
  3181.  add.w d2,d2
  3182.  add.w d1,d1
  3183.  move.w d2,d4
  3184.  add.w d4,d4
  3185.  add.w d4,d2
  3186.  move.w d1,d4
  3187.  add.w d4,d4
  3188.  add.w d4,d1
  3189.  lea (a1,d1.w),a1
  3190.  move.w (a1,d2.w),d4
  3191.  move.w #$4e75,(a1,d2.w)
  3192.  
  3193.  moveq #$777,d0
  3194.  jsr (a1)
  3195.  move.w d4,(a1,d2.w)
  3196.  
  3197.  CACHE_ON d2
  3198.  
  3199.  rts
  3200.   
  3201. storeit: dc.l 0
  3202.  
  3203. doacrossline:
  3204. val SET 0
  3205.  REPT 32
  3206.  move.w d0,val(a3)
  3207. val SET val+4
  3208.  ENDR
  3209. val SET val+4
  3210.  REPT 32
  3211.  move.w d0,val(a3)
  3212. val SET val+4
  3213.  ENDR
  3214. val SET val+4
  3215.  REPT 32
  3216.  move.w d0,val(a3)
  3217. val SET val+4
  3218.  ENDR
  3219.  rts
  3220.  
  3221. dst: dc.w 0
  3222.  
  3223. FloorLine:
  3224.  
  3225.  move.l #floortile,a0
  3226.  adda.w whichtile,a0
  3227.  move.w lighttype,d1
  3228.  
  3229.  move.w d0,dst
  3230.  
  3231.  move.w d0,d2
  3232. *********************
  3233. * Old version
  3234.  asr.w #6,d2
  3235.  add.w #5,d1
  3236. *********************
  3237. ; asr.w #3,d2
  3238. ; sub.w #4,d2
  3239. ; cmp.w #6,d2
  3240. ; blt.s flbrbr
  3241. ; move.w #6,d2
  3242. ;flbrbr:
  3243. *********************
  3244.  add.w d2,d1
  3245.  bge.s .fixedbright
  3246.  moveq #0,d1
  3247. .fixedbright:
  3248.  cmp.w #28,d1
  3249.  ble.s .smallbright
  3250.  move.w #28,d1
  3251. .smallbright:
  3252.  lea floorscalecols,a1
  3253.  add.l floorbright(pc,d1.w*4),a1
  3254.  bra pastfloorbright
  3255.  
  3256. ConstCol: dc.w 0
  3257.  
  3258. BumpLine:
  3259.  
  3260.  tst.b smoothbumps
  3261.  beq.s Chunky
  3262.  
  3263.  move.l #SmoothTile,a0
  3264.  lea Smoothscalecols,a1
  3265.  bra pastast
  3266.  
  3267. Chunky:
  3268.  
  3269.  moveq #0,d2
  3270.  move.l #Bumptile,a0
  3271.  move.w whichtile,d2
  3272.  adda.w d2,a0
  3273.  ror.l #2,d2
  3274.  lsr.w #6,d2
  3275.  rol.l #2,d2
  3276.  and.w #15,d2
  3277.  move.l #ConstCols,a1
  3278.  move.w (a1,d2.w*2),ConstCol
  3279.  lea Bumpscalecols,a1
  3280.  
  3281. pastast:
  3282.  move.w lighttype,d1
  3283.  
  3284.  move.w d0,dst
  3285.  
  3286.  move.w d0,d2
  3287. *********************
  3288. * Old version
  3289.  asr.w #6,d2
  3290.  add.w #5,d1
  3291. *********************
  3292. ; asr.w #3,d2
  3293. ; sub.w #4,d2
  3294. ; cmp.w #6,d2
  3295. ; blt.s flbrbr
  3296. ; move.w #6,d2
  3297. ;flbrbr:
  3298. *********************
  3299.  add.w d2,d1
  3300.  bge.s .fixedbright
  3301.  moveq #0,d1
  3302. .fixedbright:
  3303.  cmp.w #28,d1
  3304.  ble.s .smallbright
  3305.  move.w #28,d1
  3306. .smallbright:
  3307.  add.l floorbright(pc,d1.w*4),a1
  3308.  bra pastfloorbright
  3309.  
  3310.  
  3311. floorbright:
  3312.  dc.l 512*0
  3313.  dc.l 512*1
  3314.  dc.l 512*1
  3315.  dc.l 512*2
  3316.  dc.l 512*2
  3317.  
  3318.  dc.l 512*3
  3319.  dc.l 512*3
  3320.  dc.l 512*4
  3321.  dc.l 512*4
  3322.  dc.l 512*5
  3323.  
  3324.  dc.l 512*5
  3325.  dc.l 512*6
  3326.  dc.l 512*6
  3327.  dc.l 512*7
  3328.  dc.l 512*7
  3329.  
  3330.  dc.l 512*8
  3331.  dc.l 512*8
  3332.  dc.l 512*9
  3333.  dc.l 512*9
  3334.  dc.l 512*10
  3335.  
  3336.  dc.l 512*10
  3337.  dc.l 512*11
  3338.  dc.l 512*11
  3339.  dc.l 512*12
  3340.  dc.l 512*12
  3341.  
  3342.  dc.l 512*13
  3343.  dc.l 512*13
  3344.  dc.l 512*14
  3345.  dc.l 512*14
  3346.  
  3347. widthleft: dc.w 0
  3348. scaleval: dc.w 0
  3349. sxoff: dc.w 0
  3350. szoff: dc.w 0
  3351. xoff34: dc.w 0
  3352. zoff34: dc.w 0
  3353. scosval: dc.w 0
  3354. ssinval: dc.w 0
  3355.  
  3356.  
  3357. floorsetbright:
  3358.  move.l #walltiles,a0
  3359.  
  3360. pastfloorbright
  3361.  
  3362.  
  3363.  move.w d0,d1
  3364.  muls cosval,d1    ; change in x across whole width
  3365.  move.w d0,d2
  3366.  muls sinval,d2    ; change in z across whole width
  3367.  neg.l d2
  3368. scaleprog:
  3369.  move.w scaleval(pc),d3
  3370.  beq.s .samescale
  3371.  bgt.s .scaledown
  3372.  neg.w d3
  3373.  asr.l d3,d1
  3374.  asr.l d3,d2
  3375.  bra.s .samescale
  3376. .scaledown:
  3377.  asl.l d3,d1
  3378.  asl.l d3,d2
  3379. .samescale
  3380.  
  3381.  move.l d1,d3 ;    z cos
  3382.  move.l d3,d6
  3383.  move.l d3,d5
  3384.  asr.l #1,d6
  3385.  add.l d6,d3
  3386.  asr.l #1,d3
  3387.  
  3388.  move.l d2,d4    ; z sin
  3389.  move.l d4,d6
  3390.  asr.l #1,d6
  3391.  add.l d4,d6
  3392.  add.l d3,d4
  3393.  neg.l d4    ; start x
  3394.  
  3395.  asr.l #1,d6    ; zsin/2
  3396.  sub.l d6,d5    ; start z
  3397.  
  3398.  move.w d4,startsmoothx
  3399.  move.w d5,startsmoothz
  3400.  
  3401.  swap d4
  3402.  asr.l #8,d5
  3403.  add.w szoff,d5
  3404.  add.w sxoff,d4
  3405.  and.w #63,d4
  3406.  and.w #63*256,d5
  3407.  move.b d4,d5
  3408.  
  3409.  asr.l #6,d1
  3410.  asr.l #6,d2
  3411.  move.w leftedge(pc),d6
  3412.  beq.s nomultleft
  3413.  
  3414.  move.l d1,d3
  3415.  asr.l #6,d3
  3416.  muls d6,d3
  3417.  asl.l #6,d3
  3418.  swap d3
  3419.  add.b d3,d5
  3420.  
  3421.  move.l d2,d3
  3422.  asr.l #6,d3
  3423.  muls d6,d3
  3424.  asl.l #6,d3
  3425.  swap d3
  3426.  lsl.w #8,d3
  3427.  add.w d3,d5
  3428.  
  3429. nomultleft:
  3430.  
  3431.  move.w d1,a4
  3432.  move.w d2,a5
  3433.  asr.l #8,d2
  3434.  and.w #%0011111100000000,d2
  3435.  swap d1
  3436.  add.w d1,d2
  3437.  move.w #%11111100111111,d1
  3438.  and.w d1,d5
  3439.  swap d5
  3440.  move.w startsmoothz,d5
  3441.  swap d5
  3442.  swap d2
  3443.  move.w a5,d2
  3444.  swap d2
  3445.  
  3446. ***********************************
  3447.  
  3448.  move.w d6,a2
  3449.  move.l d2,d6
  3450.  add.w #256,d6
  3451.  
  3452.  moveq #0,d0
  3453.  
  3454.  tst.w a2
  3455.  beq startatleftedge
  3456.  
  3457.  move.w widthleft(pc),d4
  3458.  
  3459.  move.w rightedge(pc),d3
  3460.  
  3461.  cmp.w #31,a2
  3462.  bgt.s notinfirststrip
  3463.  lea (a3,a2.w*4),a3
  3464.  cmp.w #32,d3
  3465.  ble.s allinfirststrip
  3466.  move.w #32,d7
  3467.  sub.w d7,d3
  3468.  sub.w a2,d7
  3469.  bra intofirststrip
  3470.  
  3471. allinfirststrip
  3472.  sub.w a2,d3
  3473.  move.w d3,d7
  3474.  move.w #0,d4
  3475.  bra allintofirst
  3476.  
  3477. notinfirststrip:
  3478.  sub.w #32,a2
  3479.  sub.w #32,d3
  3480.  adda.w #33*4,a3
  3481.  cmp.w #31,a2
  3482.  bgt.s notstartinsec
  3483.  lea (a3,a2.w*4),a3
  3484.  cmp.w #32,d3
  3485.  ble.s allinsecstrip
  3486.  move.w #32,d7
  3487.  sub.w d7,d3
  3488.  sub.w a2,d7
  3489.  move.w d3,d4
  3490.  bra tstwat
  3491.  
  3492. allinsecstrip
  3493.  sub.w a2,d3
  3494.  move.w d3,d7
  3495.  move.w #0,d4
  3496.  bra tstwat
  3497.  rts
  3498.  
  3499. notstartinsec:
  3500.  sub.w #32,a2
  3501.  sub.w #32,d3
  3502.  adda.w #33*4,a3
  3503.  lea (a3,a2.w*4),a3
  3504.  cmp.w #32,d3
  3505.  ble.s allinthirdstrip
  3506.  move.w #32,d7
  3507.  sub.w d7,d3
  3508.  sub.w a2,d7
  3509.  move.w d3,d4
  3510.  bra tstwat
  3511.  rts
  3512.  
  3513. allinthirdstrip
  3514.  sub.w a2,d3
  3515.  move.w d3,d7
  3516.  move.w #0,d4
  3517.  bra tstwat
  3518.  rts
  3519.  
  3520. startatleftedge:
  3521.  
  3522.  move.w rightedge(pc),d3
  3523.  sub.w a2,d3
  3524.  
  3525.  move.w d3,d7
  3526.  cmp.w #32,d7
  3527.  ble.s .notoowide
  3528.  move.w #32,d7
  3529. .notoowide:
  3530.  sub.w d7,d3
  3531. intofirststrip:
  3532.  
  3533.  move.w d3,d4
  3534. allintofirst:
  3535.  
  3536.  move.w startsmoothx,d3
  3537.  
  3538. tstwat:
  3539.  
  3540.  tst.b usewater
  3541.  bne texturedwater
  3542.  
  3543.  
  3544. ******************************
  3545. * BumpMap the floor/ceiling! *
  3546.  tst.b usebumps
  3547.  bne.s BumpMap
  3548. ******************************
  3549.  
  3550. ordinary:
  3551.  moveq #0,d0
  3552.  
  3553.  dbra d7,acrossscrn
  3554.  rts
  3555.  
  3556. usebumps: dc.w $0
  3557. smoothbumps: dc.w $0
  3558.  
  3559.  include "ab3:source/bumpmap.s"
  3560.  
  3561.  CNOP 0,4
  3562. backbefore:
  3563.  and.w d1,d5
  3564.  move.b (a0,d5.w*4),d0
  3565.  move.w (a1,d0.w*2),(a3)
  3566.  addq #4,a3
  3567.  add.w a4,d3
  3568.  addx.l d6,d5
  3569.  dbcs d7,acrossscrn
  3570.  dbcc d7,backbefore
  3571.  bcc.s past1
  3572.  add.w #256,d5 
  3573.  bra.s past1
  3574.  
  3575. acrossscrn:
  3576.  and.w d1,d5
  3577.  move.b (a0,d5.w*4),d0
  3578.  move.w (a1,d0.w*2),(a3)
  3579.  addq #4,a3
  3580.  add.w a4,d3
  3581.  addx.l d2,d5
  3582.  dbcs d7,acrossscrn
  3583.  dbcc d7,backbefore
  3584.  bcc.s past1
  3585.  add.w #256,d5 
  3586. past1:
  3587.  
  3588.  move.w d4,d7
  3589.  bne.s .notdoneyet
  3590.  CACHE_FREEZE_ON d2
  3591.  rts
  3592. .notdoneyet:
  3593.  
  3594.  cmp.w #32,d7
  3595.  ble.s .notoowide
  3596.  move.w #32,d7
  3597. .notoowide
  3598.  sub.w d7,d4  
  3599.  addq #4,a3
  3600.  
  3601.  dbra d7,acrossscrn
  3602.  CACHE_FREEZE_ON d2
  3603.  rts
  3604.  
  3605. waterpt: dc.l waterlist
  3606.  
  3607. waterlist:
  3608.  dc.l waterfile
  3609.  dc.l waterfile+2
  3610.  dc.l waterfile+256
  3611.  dc.l waterfile+256+2
  3612.  dc.l waterfile+512
  3613.  dc.l waterfile+512+2
  3614.  dc.l waterfile+768
  3615.  dc.l waterfile+768+2
  3616. ; dc.l waterfile+768
  3617. ; dc.l waterfile+512+2
  3618. ; dc.l waterfile+512
  3619. ; dc.l waterfile+256+2
  3620. ; dc.l waterfile+256
  3621. ; dc.l waterfile+2
  3622. endwaterlist:
  3623.  
  3624. watertouse: dc.l waterfile
  3625.  
  3626. wtan: dc.w 0
  3627. wateroff: dc.w 0
  3628.  
  3629. texturedwater:
  3630.  
  3631.  add.w wateroff,d5
  3632.  
  3633.  move.l #brightentab,a1
  3634.  move.w dst,d0
  3635.  clr.b d0
  3636.  add.w d0,d0
  3637.  adda.w d0,a1
  3638.  
  3639.  move.w dst,d0
  3640.  asl.w #7,d0
  3641.  add.w wtan,d0
  3642.  and.w #8191,d0
  3643.  move.l #SineTable,a0
  3644.  move.w (a0,d0.w),d0
  3645.  ext.l d0
  3646.  move.w dst,d3
  3647.  add.w #300,d3
  3648.  divs d3,d0
  3649.  asr.w #6,d0
  3650.  add.w #2,d0
  3651.  
  3652.  move.w dst,d3
  3653.  asr.w #7,d3
  3654.  add.w d3,d0
  3655.  
  3656.  muls #104*4,d0
  3657.  move.w d0,a6
  3658.  
  3659.  move.l watertouse,a0
  3660.  
  3661.  move.w startsmoothx,d3
  3662.  dbra d7,acrossscrnw
  3663.  rts
  3664.  
  3665. backbeforew:
  3666.  and.w d1,d5
  3667.  move.w (a0,d5.w*4),d0
  3668.  move.b 1(a3,a6.w),d0
  3669.  move.w (a1,d0.w*2),(a3)
  3670.  addq #4,a3
  3671.  add.w a4,d3
  3672.  addx.l d6,d5
  3673.  dbcs d7,acrossscrnw
  3674.  dbcc d7,backbeforew
  3675.  bcc.s past1w
  3676.  add.w #256,d5 
  3677.  bra.s past1w
  3678.  
  3679. prot8: dc.w 0
  3680.  
  3681. acrossscrnw:
  3682.  and.w d1,d5
  3683.  move.w (a0,d5.w*4),d0
  3684.  move.b 1(a3,a6.w),d0
  3685.  move.w (a1,d0.w*2),(a3)
  3686.  addq #4,a3
  3687.  add.w a4,d3
  3688.  addx.l d2,d5
  3689.  dbcs d7,acrossscrnw
  3690.  dbcc d7,backbeforew
  3691.  bcc.s past1w
  3692.  add.w #256,d5 
  3693. past1w:
  3694.  
  3695.  move.w d4,d7
  3696.  bne.s .notdoneyet
  3697.  rts
  3698. .notdoneyet:
  3699.  
  3700.  cmp.w #32,d7
  3701.  ble.s .notoowide
  3702.  move.w #32,d7
  3703. .notoowide
  3704.  sub.w d7,d4  
  3705.  addq #4,a3
  3706.  
  3707.  dbra d7,acrossscrnw
  3708.  CACHE_FREEZE_ON d2
  3709.  rts
  3710.  
  3711. usewater: dc.w 0
  3712. startsmoothx: dc.w 0
  3713. startsmoothz: dc.w 0
  3714.  
  3715. ********************************
  3716. *
  3717.  include "AB3:source/ObjDraw3.chipram"
  3718. *
  3719. ********************************
  3720.  
  3721. numframes:
  3722.  dc.w 0
  3723.  
  3724. alframe: dc.l Objects+4096
  3725.  
  3726. alan:
  3727.  dcb.l 6,0
  3728.  dcb.l 6,1
  3729.  dcb.l 6,2
  3730.  dcb.l 6,3
  3731. endalan:
  3732.  
  3733. alanptr: dc.l alan
  3734.  
  3735. Time2: dc.l 0
  3736. dispco:
  3737.  dc.w 0
  3738.  
  3739. KInt_Init    ;VBR Assumed $0
  3740.         move.l $68.w,OLDKINT
  3741.         Move.l    #KInt_Main,$68.w    Install Interrupt 
  3742.         And.b    #$3f,$bfe201        Set Timers
  3743.         Move.b    #$7f,$bfed01
  3744.         Move.b    $bfed01,d0
  3745.         Move.b    #$88,$bfed01
  3746.         St.b    KInt_CCode        
  3747.         Move.b    #$a0,$bfee01        Start Timey Thing
  3748.         Rts                And return
  3749.  
  3750. OLDKINT: dc.l 0
  3751.  
  3752. KInt_Main    
  3753.         Movem.l    d0/d1/a0/a1/a6,-(a7)    Stack everything
  3754.         Move.w    #8,$dff09a        Temp Disable Int.
  3755.         Move.w    $dff01e,d0        Intreqr
  3756.         And.w    #8,d0            Mask Out All X^ K_Int
  3757.     Beq    KInt_End            Not Keyboard Interrupt
  3758.         Lea    $bfed01,a6
  3759.         Move.w    #$8,$dff09c        Clear Int.Request
  3760.         Move.b    -$100(a6),d0        Move Raw Keyboard value
  3761.         Ror.b    #1,d0            Roll to correct
  3762.         Not.b    d0            
  3763.         Move.b    d0,KInt_CCode        Save Corrected Keycode
  3764. .HandShake    Move.b    #8,(a6)
  3765.         Move.b    #7,-$900(a6)
  3766.         Move.b    #0,-$800(a6)
  3767.         Move.b    #0,-$100(a6)
  3768.         Move.b    #$d1,$100(a6)        
  3769.         Tst.b    (a6)    
  3770. .wait        Btst    #0,(a6)
  3771.     Beq.s    .wait
  3772.         Move.b    #$a0,$100(a6)        
  3773.         Move.b    (a6),d0        
  3774.         Move.b    #$88,(a6)
  3775.         Lea    KeyMap,a1
  3776.         Moveq.w    #0,d0
  3777.         Move.b    KInt_CCode(pc),d0
  3778.     Bmi.s    KInt_KeyUp            neg if up 
  3779.  
  3780. KInt_KeyDown
  3781.         st (a1,d0.w)
  3782.     Bra    KInt_End
  3783.  
  3784. KInt_KeyUp
  3785.         And.w    #$7f,d0            Make code Positive
  3786.         clr.b (a1,d0.w)
  3787. KInt_End    Movem.l    (a7)+,d0/d1/a0/a1/a6    Unstack Everything
  3788.     
  3789.         Move.w    #$8008,$dff09a        Re-enable Int.
  3790.         Rte
  3791.  
  3792. KInt_CCode    Ds.b    1
  3793. KInt_Askey    Ds.b    1
  3794. KInt_OCode    Ds.w    1
  3795.  
  3796.  
  3797. PLR1_mouse_control
  3798.  jsr ReadMouse
  3799.  jsr PLR1_alwayskeys
  3800.  move.l #SineTable,a0
  3801.  move.w PLR1s_angspd,d1
  3802.  move.w PLR1s_angpos,d0
  3803.  move.w (a0,d0.w),PLR1s_sinval
  3804.  adda.w #2048,a0
  3805.  move.w (a0,d0.w),PLR1s_cosval
  3806.  
  3807.  move.l PLR1s_xspdval,d6
  3808.  move.l PLR1s_zspdval,d7
  3809.  
  3810.  neg.l d6
  3811.  ble.s .nobug1
  3812.  asr.l #1,d6
  3813.  add.l #1,d6
  3814.  bra.s .bug1
  3815. .nobug1
  3816.  asr.l #1,d6
  3817. .bug1:
  3818.  
  3819.  neg.l d7
  3820.  ble.s .nobug2
  3821.  asr.l #1,d7
  3822.  add.l #1,d7
  3823.  bra.s .bug2
  3824. .nobug2
  3825.  asr.l #1,d7
  3826. .bug2: 
  3827.  
  3828.  
  3829.  move.w ymouse,d3
  3830.  sub.w oldymouse,d3
  3831.  add.w d3,oldymouse
  3832.  asr.w #1,d3
  3833.  cmp.w #50,d3
  3834.  ble.s nofastfor
  3835.  move.w #50,d3
  3836. nofastfor:
  3837.  cmp.w #-50,d3
  3838.  bge.s nofastback
  3839.  move.w #-50,d3
  3840. nofastback:
  3841.  
  3842.  move.w d3,d2
  3843.  asl.w #3,d2
  3844.  move.w d2,d1
  3845.  add.w d2,d1
  3846.  add.w d2,d1
  3847.  add.w Bobble,d1
  3848.  and.w #8190,d1
  3849.  move.w d1,Bobble
  3850.  
  3851.  move.w PLR1s_sinval,d1
  3852.  move.w PLR1s_cosval,d2
  3853.  
  3854.  move.w d2,d4
  3855.  move.w d1,d5
  3856.  muls lrs,d4
  3857.  muls lrs,d5
  3858.  
  3859.  
  3860.  muls d3,d2
  3861.  muls d3,d1
  3862.  sub.l d4,d1
  3863.  add.l d5,d2
  3864.  
  3865.  sub.l d1,d6
  3866.  sub.l d2,d7
  3867.  add.l d6,PLR1s_xspdval
  3868.  add.l d7,PLR1s_zspdval
  3869.  move.l PLR1s_xspdval,d6
  3870.  move.l PLR1s_zspdval,d7
  3871.  add.l d6,PLR1s_xoff
  3872.  add.l d7,PLR1s_zoff
  3873.  
  3874.  tst.b PLR1_fire
  3875.  beq.s .firenotpressed
  3876. ; fire was pressed last time.
  3877.  btst #6,$bfe001
  3878.  bne.s .firenownotpressed
  3879. ; fire is still pressed this time.
  3880.  st PLR1_fire
  3881.  bra .doneplr1
  3882.  
  3883. .firenownotpressed:
  3884. ; fire has been released.
  3885.  clr.b PLR1_fire
  3886.  bra .doneplr1
  3887.  
  3888. .firenotpressed
  3889.  
  3890. ; fire was not pressed last frame...
  3891.  
  3892.  btst #6,$bfe001
  3893. ; if it has still not been pressed, go back above
  3894.  bne.s .firenownotpressed
  3895. ; fire was not pressed last time, and was this time, so has
  3896. ; been clicked.
  3897.  st PLR1_clicked
  3898.  st PLR1_fire
  3899.  
  3900. .doneplr1:
  3901.  move.l PLR1s_tyoff,d0
  3902.  move.l PLR1s_yoff,d1
  3903.  move.l PLR1s_yvel,d2
  3904.  sub.l d1,d0
  3905.  bgt.s .aboveground
  3906.  sub.l #1024,d2
  3907.  blt.s .notfast
  3908.  sub.l #2048,d2
  3909. .notfast:
  3910.  add.l d2,d1
  3911.  sub.l d2,d0
  3912.  blt.s .pastitall
  3913.  move.l #0,d2
  3914.  add.l d0,d1
  3915.  bra.s .pastitall
  3916.  
  3917. .aboveground:
  3918.  add.l d2,d1
  3919.  add.l #1024,d2
  3920. .pastitall:
  3921.  
  3922.  move.l d2,PLR1s_yvel
  3923.  move.l d1,PLR1s_yoff
  3924.  
  3925.  rts
  3926.  
  3927. PLR1_follow_path:
  3928.  
  3929.  move.l pathpt,a0
  3930.  move.w (a0),d1
  3931.  move.w d1,PLR1s_xoff
  3932.  move.w 2(a0),d1
  3933.  move.w d1,PLR1s_zoff
  3934.  move.w 4(a0),d0
  3935.  add.w d0,d0
  3936.  and.w #8190,d0
  3937.  move.w d0,PLR1_angpos
  3938.  
  3939.  move.w TempFrames,d0
  3940.  asl.w #3,d0
  3941.  adda.w d0,a0
  3942.  
  3943.  cmp.l #endpath,a0
  3944.  blt notrestartpath
  3945.  move.l #Path,a0
  3946. notrestartpath:
  3947.  move.l a0,pathpt
  3948.  
  3949.  rts
  3950.  
  3951. OldSpace: dc.b 0
  3952. SpaceTapped: dc.b 0
  3953. SPCTAP: dc.b 0
  3954.  even
  3955.  
  3956. PLR1_alwayskeys
  3957.  move.l #KeyMap,a5
  3958.  move.b $40(a5),d1
  3959.  beq.s nottapped
  3960.  tst.b OldSpace
  3961.  bne.s nottapped
  3962.  st SpaceTapped
  3963. nottapped:
  3964.  move.b d1,OldSpace
  3965.  
  3966.  lea 1(a5),a4
  3967.  lea GunData,a3
  3968.  moveq #0,d0
  3969.  move.w #4,d1
  3970. pickweap
  3971.  tst.b (a4)+
  3972.  beq.s notgotweap
  3973.  tst.b 7(a3)
  3974.  beq.s notgotweap
  3975.  move.b d0,GunSelected
  3976. notgotweap
  3977.  addq #1,d0
  3978.  addq #8,a3
  3979.  dbra d1,pickweap
  3980.  
  3981.  rts
  3982.  
  3983. PLR1_keyboard_control:
  3984.  
  3985.  move.l #SineTable,a0
  3986.  
  3987.  jsr PLR1_alwayskeys
  3988.  move.l #KeyMap,a5
  3989.  
  3990.  move.w PLR1s_angpos,d0
  3991.  move.w #70,d1
  3992.  move.w #7,d2
  3993.  tst.b $61(a5)
  3994.  beq.s nofaster
  3995.  move.w #120,d1
  3996.  move.w #10,d2
  3997. nofaster:
  3998.  
  3999.  moveq #0,d4 
  4000. ; tst.b $67(a5)
  4001. ; bne.s slidelr
  4002.  
  4003.  tst.b $4f(a5)
  4004.  beq.s noleftturn
  4005.  sub.w d1,d0
  4006. noleftturn
  4007.  move.l #KeyMap,a5
  4008.  tst.b $4e(a5)
  4009.  beq.s norightturn
  4010.  add.w d1,d0
  4011. norightturn
  4012. ; bra.s noslide
  4013.  
  4014. slidelr:
  4015.  tst.b $39(a5)
  4016.  beq.s noleftslide
  4017.  move.w d2,d4
  4018.  asr.w #1,d4
  4019. noleftslide
  4020.  move.l #KeyMap,a5
  4021.  tst.b $3a(a5)
  4022.  beq.s norightslide
  4023.  sub.w d2,d4
  4024.  asr.w #1,d4
  4025. norightslide
  4026.   
  4027. noslide:
  4028.   
  4029.  and.w #8191,d0
  4030.  move.w d0,PLR1s_angpos
  4031.  
  4032.  move.w (a0,d0.w),PLR1s_sinval
  4033.  adda.w #2048,a0
  4034.  move.w (a0,d0.w),PLR1s_cosval
  4035.  
  4036.  move.l PLR1s_xspdval,d6
  4037.  move.l PLR1s_zspdval,d7
  4038.  
  4039.  neg.l d6
  4040.  ble.s .nobug1
  4041.  asr.l #1,d6
  4042.  add.l #1,d6
  4043.  bra.s .bug1
  4044. .nobug1
  4045.  asr.l #1,d6
  4046. .bug1:
  4047.  
  4048.  neg.l d7
  4049.  ble.s .nobug2
  4050.  asr.l #1,d7
  4051.  add.l #1,d7
  4052.  bra.s .bug2
  4053. .nobug2
  4054.  asr.l #1,d7
  4055. .bug2: 
  4056.  
  4057.  moveq #0,d3
  4058.  
  4059.  tst.b $4c(a5)
  4060.  beq.s noforward
  4061.  neg.w d2
  4062.  move.w d2,d3
  4063.  
  4064. noforward:
  4065.  tst.b $4d(a5)
  4066.  beq.s nobackward
  4067.  move.w d2,d3
  4068. nobackward:
  4069.  
  4070.  move.w d3,d2
  4071.  asl.w #3,d2
  4072.  move.w d2,d1
  4073.  add.w d2,d1
  4074.  add.w d2,d1
  4075.  add.w Bobble,d1
  4076.  and.w #8190,d1
  4077.  move.w d1,Bobble
  4078.  
  4079.  move.w PLR1s_sinval,d1
  4080.  muls d3,d1
  4081.  move.w PLR1s_cosval,d2
  4082.  muls d3,d2
  4083.  
  4084.  sub.l d1,d6
  4085.  sub.l d2,d7
  4086.  move.w PLR1s_sinval,d1
  4087.  muls d4,d1
  4088.  move.w PLR1s_cosval,d2
  4089.  muls d4,d2
  4090.  sub.l d2,d6
  4091.  add.l d1,d7
  4092.  
  4093.  add.l d6,PLR1s_xspdval
  4094.  add.l d7,PLR1s_zspdval
  4095.  move.l PLR1s_xspdval,d6
  4096.  move.l PLR1s_zspdval,d7
  4097.  add.l d6,PLR1s_xoff
  4098.  add.l d7,PLR1s_zoff
  4099.  
  4100.  tst.b PLR1_fire
  4101.  beq.s .firenotpressed
  4102. ; fire was pressed last time.
  4103.  tst.b $65(a5)
  4104.  beq.s .firenownotpressed
  4105. ; fire is still pressed this time.
  4106.  st PLR1_fire
  4107.  bra .doneplr1
  4108.  
  4109. .firenownotpressed:
  4110. ; fire has been released.
  4111.  clr.b PLR1_fire
  4112.  bra .doneplr1
  4113.  
  4114. .firenotpressed
  4115.  
  4116. ; fire was not pressed last frame...
  4117.  
  4118.  tst.b $65(a5)
  4119. ; if it has still not been pressed, go back above
  4120.  beq.s .firenownotpressed
  4121. ; fire was not pressed last time, and was this time, so has
  4122. ; been clicked.
  4123.  st PLR1_clicked
  4124.  st PLR1_fire
  4125.  
  4126. .doneplr1:
  4127.  
  4128.  move.l PLR1s_tyoff,d0
  4129.  move.l PLR1s_yoff,d1
  4130.  move.l PLR1s_yvel,d2
  4131.  sub.l d1,d0
  4132.  bgt.s .aboveground
  4133.  sub.l #512,d2
  4134.  blt.s .notfast
  4135.  move.l #0,d2
  4136. .notfast:
  4137.  add.l d2,d1
  4138.  sub.l d2,d0
  4139.  blt.s .pastitall
  4140.  move.l #0,d2
  4141.  add.l d0,d1
  4142.  bra.s .pastitall
  4143.  
  4144. .aboveground:
  4145.  add.l d2,d1
  4146.  add.l #1024,d2
  4147. .pastitall:
  4148.  
  4149.  move.l d2,PLR1s_yvel
  4150.  move.l d1,PLR1s_yoff
  4151.  
  4152.  rts
  4153.  
  4154. PLR1_JoyStick_control:
  4155.  
  4156.  move.l #KeyMap,a5
  4157.  move.l #SineTable,a0
  4158.  
  4159.  btst #1,$dff00c
  4160.  sne d0
  4161.  btst #1,$dff00d
  4162.  sne d1
  4163.  btst #0,$dff00c
  4164.  sne d2
  4165.  btst #0,$dff00d
  4166.  sne d3
  4167.  btst #7,$bfe001
  4168.  seq $65(a5)
  4169.  
  4170.  move.b d0,$4f(a5)
  4171.  move.b d1,$4e(a5)
  4172.  eor.b d0,d2
  4173.  move.b d2,$4c(a5)
  4174.  eor.b d1,d3
  4175.  move.b d3,$4d(a5)
  4176.  
  4177.  jsr PLR1_alwayskeys
  4178.  
  4179.  move.w PLR1s_angpos,d0
  4180.  move.w #70,d1
  4181.  move.w #7,d2
  4182.  tst.b $61(a5)
  4183.  beq.s .nofaster
  4184.  move.w #120,d1
  4185.  move.w #10,d2
  4186. .nofaster:
  4187.  
  4188.  moveq #0,d4 
  4189. ; tst.b $67(a5)
  4190. ; bne.s slidelr
  4191.  
  4192.  tst.b $4f(a5)
  4193.  beq.s .noleftturn
  4194.  sub.w d1,d0
  4195. .noleftturn
  4196.  move.l #KeyMap,a5
  4197.  tst.b $4e(a5)
  4198.  beq.s .norightturn
  4199.  add.w d1,d0
  4200. .norightturn
  4201. ; bra.s noslide
  4202.  
  4203. .slidelr:
  4204.  tst.b $39(a5)
  4205.  beq.s .noleftslide
  4206.  move.w d2,d4
  4207.  asr.w #1,d4
  4208. .noleftslide
  4209.  move.l #KeyMap,a5
  4210.  tst.b $3a(a5)
  4211.  beq.s .norightslide
  4212.  sub.w d2,d4
  4213.  asr.w #1,d4
  4214. .norightslide
  4215.   
  4216. .noslide:
  4217.   
  4218.  and.w #8191,d0
  4219.  move.w d0,PLR1s_angpos
  4220.  
  4221.  move.w (a0,d0.w),PLR1s_sinval
  4222.  adda.w #2048,a0
  4223.  move.w (a0,d0.w),PLR1s_cosval
  4224.  
  4225.  move.l PLR1s_xspdval,d6
  4226.  move.l PLR1s_zspdval,d7
  4227.  
  4228.  neg.l d6
  4229.  ble.s .nobug1
  4230.  asr.l #1,d6
  4231.  add.l #1,d6
  4232.  bra.s .bug1
  4233. .nobug1
  4234.  asr.l #1,d6
  4235. .bug1:
  4236.  
  4237.  neg.l d7
  4238.  ble.s .nobug2
  4239.  asr.l #1,d7
  4240.  add.l #1,d7
  4241.  bra.s .bug2
  4242. .nobug2
  4243.  asr.l #1,d7
  4244. .bug2: 
  4245.  
  4246.  moveq #0,d3
  4247.  
  4248.  tst.b $4c(a5)
  4249.  beq.s .noforward
  4250.  neg.w d2
  4251.  move.w d2,d3
  4252. .noforward:
  4253.  tst.b $4d(a5)
  4254.  beq.s .nobackward
  4255.  move.w d2,d3
  4256. .nobackward:
  4257.  
  4258.  move.w d3,d2
  4259.  asl.w #3,d2
  4260.  move.w d2,d1
  4261.  add.w d2,d1
  4262.  add.w d2,d1
  4263.  add.w Bobble,d1
  4264.  and.w #8190,d1
  4265.  move.w d1,Bobble
  4266.  
  4267.  move.w PLR1s_sinval,d1
  4268.  muls d3,d1
  4269.  move.w PLR1s_cosval,d2
  4270.  muls d3,d2
  4271.  
  4272.  sub.l d1,d6
  4273.  sub.l d2,d7
  4274.  move.w PLR1s_sinval,d1
  4275.  muls d4,d1
  4276.  move.w PLR1s_cosval,d2
  4277.  muls d4,d2
  4278.  sub.l d2,d6
  4279.  add.l d1,d7
  4280.  
  4281.  add.l d6,PLR1s_xspdval
  4282.  add.l d7,PLR1s_zspdval
  4283.  move.l PLR1s_xspdval,d6
  4284.  move.l PLR1s_zspdval,d7
  4285.  add.l d6,PLR1s_xoff
  4286.  add.l d7,PLR1s_zoff
  4287.  
  4288.  tst.b PLR1_fire
  4289.  beq.s .firenotpressed
  4290. ; fire was pressed last time.
  4291.  tst.b $65(a5)
  4292.  beq.s .firenownotpressed
  4293. ; fire is still pressed this time.
  4294.  st PLR1_fire
  4295.  bra .doneplr1
  4296.  
  4297. .firenownotpressed:
  4298. ; fire has been released.
  4299.  clr.b PLR1_fire
  4300.  bra .doneplr1
  4301.  
  4302. .firenotpressed
  4303.  
  4304. ; fire was not pressed last frame...
  4305.  
  4306.  tst.b $65(a5)
  4307. ; if it has still not been pressed, go back above
  4308.  beq.s .firenownotpressed
  4309. ; fire was not pressed last time, and was this time, so has
  4310. ; been clicked.
  4311.  st PLR1_clicked
  4312.  st PLR1_fire
  4313.  
  4314. .doneplr1:
  4315.  
  4316.  move.l PLR1s_tyoff,d0
  4317.  move.l PLR1s_yoff,d1
  4318.  move.l PLR1s_yvel,d2
  4319.  sub.l d1,d0
  4320.  bgt.s .aboveground
  4321.  sub.l #512,d2
  4322.  blt.s .notfast
  4323.  move.l #0,d2
  4324. .notfast:
  4325.  add.l d2,d1
  4326.  sub.l d2,d0
  4327.  blt.s .pastitall
  4328.  move.l #0,d2
  4329.  add.l d0,d1
  4330.  bra.s .pastitall
  4331.  
  4332. .aboveground:
  4333.  add.l d2,d1
  4334.  add.l #1024,d2
  4335. .pastitall:
  4336.  
  4337.  move.l d2,PLR1s_yvel
  4338.  move.l d1,PLR1s_yoff
  4339.  
  4340.  rts
  4341.  
  4342.  
  4343. Chan0inter:
  4344.  
  4345.  move.w #$0010,$dff000+intreq
  4346.  
  4347.  tst.b doanything
  4348.  bne.s dosomething
  4349.  rte
  4350.  
  4351. dosomething:
  4352.  
  4353.  addq.w #1,FramesToDraw
  4354.  tst.b counting
  4355.  beq nostopcounter
  4356.  JSR STOPCOUNTNOADD
  4357. nostopcounter:
  4358.  movem.l d0-d7/a0-a6,-(a7)
  4359.  
  4360.  cmp.b #'b',Prefsfile+3
  4361.  bne.s .noback
  4362.  jsr mt_music
  4363. .noback:
  4364.  
  4365.  bra dontshowtime
  4366.  
  4367.  tst.b oktodisplay
  4368.  beq dontshowtime
  4369.  clr.b oktodisplay
  4370.  subq.w #1,dispco
  4371.  bgt dontshowtime
  4372.  move.w #10,dispco
  4373.  
  4374.  move.l #TimerScr+10,a0
  4375.  move.l TimeCount,d0
  4376.  bge.s timenotneg
  4377.  move.l #1111*256,d0
  4378. timenotneg:
  4379.  asr.l #8,d0
  4380.  move.l #digits,a1
  4381.  move.w #7,d2
  4382. digitlop
  4383.  divs #10,d0
  4384.  swap d0
  4385.  lea (a1,d0.w*8),a2
  4386.  move.b (a2)+,(a0)
  4387.  move.b (a2)+,24(a0)
  4388.  move.b (a2)+,24*2(a0)
  4389.  move.b (a2)+,24*3(a0)
  4390.  move.b (a2)+,24*4(a0)
  4391.  move.b (a2)+,24*5(a0)
  4392.  move.b (a2)+,24*6(a0)
  4393.  move.b (a2)+,24*7(a0)
  4394.  subq #1,a0
  4395.  swap d0
  4396.  ext.l d0
  4397.  dbra d2,digitlop
  4398.  
  4399.  move.l #TimerScr+10+24*10,a0
  4400.  move.l NumTimes,d0
  4401.  move.l #digits,a1
  4402.  move.w #3,d2
  4403. digitlop2
  4404.  divs #10,d0
  4405.  swap d0
  4406.  lea (a1,d0.w*8),a2
  4407.  move.b (a2)+,(a0)
  4408.  move.b (a2)+,24(a0)
  4409.  move.b (a2)+,24*2(a0)
  4410.  move.b (a2)+,24*3(a0)
  4411.  move.b (a2)+,24*4(a0)
  4412.  move.b (a2)+,24*5(a0)
  4413.  move.b (a2)+,24*6(a0)
  4414.  move.b (a2)+,24*7(a0)
  4415.  subq #1,a0
  4416.  swap d0
  4417.  ext.l d0
  4418.  dbra d2,digitlop2
  4419.  
  4420.  move.l #TimerScr+10+24*20,a0
  4421.  moveq #0,d0
  4422.  move.w FramesToDraw,d0
  4423.  move.l #digits,a1
  4424.  move.w #2,d2
  4425. digitlop3
  4426.  divs #10,d0
  4427.  swap d0
  4428.  lea (a1,d0.w*8),a2
  4429.  move.b (a2)+,(a0)
  4430.  move.b (a2)+,24(a0)
  4431.  move.b (a2)+,24*2(a0)
  4432.  move.b (a2)+,24*3(a0)
  4433.  move.b (a2)+,24*4(a0)
  4434.  move.b (a2)+,24*5(a0)
  4435.  move.b (a2)+,24*6(a0)
  4436.  move.b (a2)+,24*7(a0)
  4437.  subq #1,a0
  4438.  swap d0
  4439.  ext.l d0
  4440.  dbra d2,digitlop3
  4441.  
  4442. dontshowtime:
  4443.  
  4444.  move.w Robotanimpos,d0
  4445.  add.w #6*38,d0
  4446.  cmp.w #6*38*64,d0
  4447.  blt.s norebot
  4448.  move.w #0,d0
  4449. norebot:
  4450.  move.w d0,Robotanimpos
  4451.  
  4452.  tst.w d0
  4453.  seq d1
  4454.  cmp.w #6*32*38,d0
  4455.  seq d2
  4456.  or.b d2,d1
  4457.  or.b d1,clump
  4458.  
  4459.  move.w Robotarmpos,d0
  4460.  add.w #6*14,d0
  4461.  cmp.w #6*14*64,d0
  4462.  blt.s norebot2
  4463.  move.w #0,d0
  4464. norebot2:
  4465.  move.w d0,Robotarmpos
  4466.  
  4467.  move.l alanptr,a0
  4468.  move.l (a0)+,alframe
  4469.  cmp.l #endalan,a0
  4470.  blt.s nostartalan
  4471.  move.l #alan,a0
  4472. nostartalan:
  4473.  move.l a0,alanptr
  4474.  
  4475.  move.l #$dff000,a6
  4476.  
  4477.  cmp.b #'4',Prefsfile+1
  4478.  bne.s nomuckabout
  4479.  
  4480.  move.w #$0,d0 
  4481.  tst.b NoiseMade0LEFT
  4482.  beq.s noturnoff0
  4483.  move.w #1,d0
  4484. noturnoff0:
  4485.  tst.b NoiseMade0RIGHT
  4486.  beq.s noturnoff1
  4487.  or.w #2,d0
  4488. noturnoff1:
  4489.  tst.b NoiseMade1RIGHT
  4490.  beq.s noturnoff2
  4491.  or.w #4,d0
  4492. noturnoff2:
  4493.  tst.b NoiseMade1LEFT
  4494.  beq.s noturnoff3
  4495.  or.w #8,d0
  4496. noturnoff3:
  4497.  move.w d0,dmacon(a6)
  4498.  
  4499. nomuckabout:
  4500.  
  4501.  tst.b PLR1MOUSE
  4502.  beq.s PLR1_nomouse
  4503.  bsr PLR1_mouse_control
  4504. PLR1_nomouse:
  4505.  tst.b PLR1KEYS
  4506.  beq.s PLR1_nokeys
  4507.  bsr PLR1_keyboard_control
  4508. PLR1_nokeys:
  4509. ; tst.b PLR1PATH
  4510. ; beq.s PLR1_nopath
  4511. ; bsr PLR1_follow_path
  4512. ;PLR1_nopath:
  4513.  tst.b PLR1JOY
  4514.  beq.s PLR1_nojoy
  4515.  bsr PLR1_JoyStick_control
  4516. PLR1_nojoy: 
  4517.  
  4518. ; tst.b PLR2_fire
  4519. ; beq.s firenotpressed2
  4520. ; fire was pressed last time.
  4521. ; btst #7,$bfe001
  4522. ; bne.s firenownotpressed2
  4523. ; fire is still pressed this time.
  4524. ; st PLR2_fire
  4525. ; bra dointer
  4526.  
  4527. firenownotpressed2:
  4528. ; fire has been released.
  4529. ; clr.b PLR2_fire
  4530. ; bra dointer
  4531.  
  4532. firenotpressed2
  4533.  
  4534. ; fire was not pressed last frame...
  4535.  
  4536. ; btst #7,$bfe001
  4537. ; if it has still not been pressed, go back above
  4538. ; bne.s firenownotpressed2
  4539. ; fire was not pressed last time, and was this time, so has
  4540. ; been clicked.
  4541. ; st PLR2_clicked
  4542. ; st PLR2_fire
  4543.  
  4544. dointer
  4545.  
  4546.  cmp.b #'4',Prefsfile+1
  4547.  beq fourchannel
  4548.  
  4549.  btst #1,$dff000+intreqr
  4550.  bne.s newsampbitl
  4551.  
  4552.  movem.l (a7)+,d0-d7/a0-a6
  4553.  tst.b counting
  4554.  beq .nostartcounter
  4555.  JSR STARTCOUNT
  4556. .nostartcounter:
  4557. noneed:
  4558.  
  4559.  rte
  4560.  
  4561. swappedem: dc.w 0
  4562.  
  4563. newsampbitl:
  4564.  
  4565.  move.w #$820f,$dff000+dmacon
  4566.  
  4567.  move.w #$200,$dff000+intreq
  4568.  
  4569.  tst.b CHANNELDATA
  4570.  bne nochannel0
  4571.  
  4572.  move.l pos0LEFT,a0
  4573.  move.l pos2LEFT,a1
  4574.  
  4575.  move.l #tab,a2
  4576.  
  4577.  moveq #0,d0
  4578.  moveq #0,d1
  4579.  move.b vol0left,d0
  4580.  move.b vol2left,d1
  4581.  cmp.b d1,d0
  4582.  slt swappedem
  4583.  bge.s fbig0
  4584.  
  4585. ; d1 is bigger so scale d0 and use d1
  4586. ; as audiochannel volume.
  4587.  
  4588.  exg a0,a1
  4589.  asl.w #6,d0
  4590.  divs d1,d0
  4591.  lsl.w #8,d0
  4592.  adda.w d0,a2
  4593.  move.w d1,$dff0a8
  4594.  bra.s donechan0
  4595.  
  4596. fbig0:
  4597.  tst.w d0
  4598.  beq.s donechan0
  4599.  asl.w #6,d1
  4600.  divs d0,d1
  4601.  lsl.w #8,d1
  4602.  adda.w d1,a2
  4603.  move.w d0,$dff0a8
  4604.  
  4605. donechan0:
  4606.  
  4607.  move.l Aupt0,a3
  4608.  move.l a3,$dff0a0
  4609.  move.l Auback0,Aupt0
  4610.  move.l a3,Auback0
  4611.  
  4612.  move.l Auback0,a3
  4613.  
  4614.  moveq #0,d0
  4615.  moveq #0,d1
  4616.  moveq #0,d2
  4617.  moveq #0,d3
  4618.  moveq #0,d4
  4619.  moveq #0,d5
  4620.  move.w #49,d7
  4621. loop:
  4622.  move.l (a0)+,d0
  4623.  move.b (a1)+,d1
  4624.  move.b (a1)+,d2
  4625.  move.b (a1)+,d3
  4626.  move.b (a1)+,d4
  4627.  move.b (a2,d3.w),d5
  4628.  swap d5
  4629.  move.b (a2,d1.w),d5
  4630.  asl.l #8,d5
  4631.  move.b (a2,d2.w),d5
  4632.  swap d5
  4633.  move.b (a2,d4.w),d5
  4634.  add.l d5,d0
  4635.  move.l d0,(a3)+
  4636.  dbra d7,loop
  4637.  
  4638.  tst.b swappedem
  4639.  beq.s .ok23
  4640.  exg a0,a1
  4641. .ok23:
  4642.  
  4643.  cmp.l Samp0endLEFT,a0
  4644.  blt.s .notoffendsamp1
  4645.  move.l #empty,a0
  4646.  move.l #emptyend,Samp0endLEFT
  4647.  move.b #0,vol0left
  4648.  st LEFTCHANDATA+1
  4649.  move.w #0,LEFTCHANDATA+2
  4650. .notoffendsamp1:
  4651.  
  4652.  cmp.l Samp2endLEFT,a1
  4653.  blt.s .notoffendsamp2
  4654.  move.l #empty,a1
  4655.  move.l #emptyend,Samp2endLEFT
  4656.  move.b #0,vol2left
  4657.  st LEFTCHANDATA+1+8
  4658.  move.w #0,LEFTCHANDATA+2+8
  4659. .notoffendsamp2:
  4660.  
  4661.  move.l a0,pos0LEFT
  4662.  move.l a1,pos2LEFT
  4663.  
  4664. nochannel0:
  4665.  
  4666.  tst.b CHANNELDATA+16
  4667.  bne nochannel1
  4668.  
  4669.  
  4670.  move.l pos0RIGHT,a0
  4671.  move.l pos2RIGHT,a1
  4672.  
  4673.  move.l Aupt1,a3
  4674.  move.l a3,$dff0b0
  4675.  move.l Auback1,Aupt1
  4676.  move.l a3,Auback1
  4677.  
  4678.  move.l #tab,a2
  4679.  
  4680.  moveq #0,d0
  4681.  moveq #0,d1
  4682.  move.b vol0right,d0
  4683.  move.b vol2right,d1
  4684.  cmp.b d1,d0
  4685.  slt swappedem
  4686.  bge.s fbig1
  4687.  
  4688. ; d1 is bigger so scale d0 and use d1
  4689. ; as audiochannel volume.
  4690.  
  4691.  exg a0,a1
  4692.  asl.w #6,d0
  4693.  divs d1,d0
  4694.  lsl.w #8,d0
  4695.  adda.w d0,a2
  4696.  move.w d1,$dff0b8
  4697.  bra.s donechan1
  4698.  
  4699. fbig1:
  4700.  tst.w d0
  4701.  beq.s donechan1
  4702.  asl.w #6,d1
  4703.  divs d0,d1
  4704.  lsl.w #8,d1
  4705.  adda.w d1,a2
  4706.  move.w d0,$dff0b8
  4707.  
  4708. donechan1:
  4709.  moveq #0,d0
  4710.  moveq #0,d1
  4711.  moveq #0,d2
  4712.  moveq #0,d3
  4713.  moveq #0,d4
  4714.  moveq #0,d5
  4715.  move.w #49,d7
  4716. loop2:
  4717.  move.l (a0)+,d0
  4718.  move.b (a1)+,d1
  4719.  move.b (a1)+,d2
  4720.  move.b (a1)+,d3
  4721.  move.b (a1)+,d4
  4722.  move.b (a2,d3.w),d5
  4723.  swap d5
  4724.  move.b (a2,d1.w),d5
  4725.  asl.l #8,d5
  4726.  move.b (a2,d2.w),d5
  4727.  swap d5
  4728.  move.b (a2,d4.w),d5
  4729.  add.l d5,d0
  4730.  move.l d0,(a3)+
  4731.  dbra d7,loop2
  4732.  
  4733.  tst.b swappedem
  4734.  beq.s ok01
  4735.  exg a0,a1
  4736. ok01:
  4737.  
  4738.  cmp.l Samp0endRIGHT,a0
  4739.  blt.s .notoffendsamp1
  4740.  move.l #empty,a0
  4741.  move.l #emptyend,Samp0endRIGHT
  4742.  move.b #0,vol0right
  4743.  st RIGHTCHANDATA+1
  4744.  move.w #0,RIGHTCHANDATA+2
  4745. .notoffendsamp1:
  4746.  
  4747.  cmp.l Samp2endRIGHT,a1
  4748.  blt.s .notoffendsamp2
  4749.  move.l #empty,a1
  4750.  move.l #emptyend,Samp2endRIGHT
  4751.  move.b #0,vol2right
  4752.  st RIGHTCHANDATA+1+8
  4753.  move.w #0,RIGHTCHANDATA+2+8
  4754. .notoffendsamp2:
  4755.  
  4756.  move.l a0,pos0RIGHT
  4757.  move.l a1,pos2RIGHT
  4758.  
  4759. nochannel1:
  4760.  
  4761. ******************* Other two channels
  4762.  
  4763.  move.l pos1LEFT,a0
  4764.  move.l pos3LEFT,a1
  4765.  
  4766.  move.l #tab,a2
  4767.  
  4768.  moveq #0,d0
  4769.  moveq #0,d1
  4770.  move.b vol1left,d0
  4771.  move.b vol3left,d1
  4772.  cmp.b d1,d0
  4773.  slt swappedem
  4774.  bge.s fbig2
  4775.  
  4776. ; d1 is bigger so scale d0 and use d1
  4777. ; as audiochannel volume.
  4778.  
  4779.  exg a0,a1
  4780.  asl.w #6,d0
  4781.  divs d1,d0
  4782.  lsl.w #8,d0
  4783.  adda.w d0,a2
  4784.  move.w d1,$dff0d8
  4785.  bra.s donechan2
  4786.  
  4787. fbig2:
  4788.  tst.w d0
  4789.  beq.s donechan2
  4790.  asl.w #6,d1
  4791.  divs d0,d1
  4792.  lsl.w #8,d1
  4793.  adda.w d1,a2
  4794.  move.w d0,$dff0d8
  4795.  
  4796. donechan2:
  4797.  
  4798.  move.l Aupt2,a3
  4799.  move.l a3,$dff0d0
  4800.  move.l Auback2,Aupt2
  4801.  move.l a3,Auback2
  4802.  
  4803.  moveq #0,d0
  4804.  moveq #0,d1
  4805.  moveq #0,d2
  4806.  moveq #0,d3
  4807.  moveq #0,d4
  4808.  moveq #0,d5
  4809.  move.w #49,d7
  4810. loop3:
  4811.  move.l (a0)+,d0
  4812.  move.b (a1)+,d1
  4813.  move.b (a1)+,d2
  4814.  move.b (a1)+,d3
  4815.  move.b (a1)+,d4
  4816.  move.b (a2,d3.w),d5
  4817.  swap d5
  4818.  move.b (a2,d1.w),d5
  4819.  asl.l #8,d5
  4820.  move.b (a2,d2.w),d5
  4821.  swap d5
  4822.  move.b (a2,d4.w),d5
  4823.  add.l d5,d0
  4824.  move.l d0,(a3)+
  4825.  dbra d7,loop3
  4826.  
  4827.  tst.b swappedem
  4828.  beq.s .ok23
  4829.  exg a0,a1
  4830. .ok23:
  4831.  
  4832.  cmp.l Samp1endLEFT,a0
  4833.  blt.s .notoffendsamp3
  4834.  move.l #empty,a0
  4835.  move.l #emptyend,Samp1endLEFT
  4836.  move.b #0,vol1left
  4837.  st LEFTCHANDATA+1+4
  4838.  move.w #0,LEFTCHANDATA+2+4
  4839. .notoffendsamp3:
  4840.  
  4841.  cmp.l Samp3endLEFT,a1
  4842.  blt.s .notoffendsamp4
  4843.  move.l #empty,a1
  4844.  move.l #emptyend,Samp3endLEFT
  4845.  move.b #0,vol3left
  4846.  st LEFTCHANDATA+1+12
  4847.  move.w #0,LEFTCHANDATA+2+12
  4848. .notoffendsamp4:
  4849.  
  4850.  move.l a0,pos1LEFT
  4851.  move.l a1,pos3LEFT
  4852.  
  4853.  move.l pos1RIGHT,a0
  4854.  move.l pos3RIGHT,a1
  4855.  
  4856.  move.l Aupt3,a3
  4857.  move.l a3,$dff0c0
  4858.  move.l Auback3,Aupt3
  4859.  move.l a3,Auback3
  4860.  
  4861.  move.l #tab,a2
  4862.  
  4863.  moveq #0,d0
  4864.  moveq #0,d1
  4865.  move.b vol1right,d0
  4866.  move.b vol3right,d1
  4867.  cmp.b d1,d0
  4868.  slt.s swappedem
  4869.  bge.s fbig3
  4870.  
  4871.  exg a0,a1
  4872.  asl.w #6,d0
  4873.  divs d1,d0
  4874.  lsl.w #8,d0
  4875.  adda.w d0,a2
  4876.  move.w d1,$dff0c8
  4877.  bra.s donechan3
  4878.  
  4879. fbig3:
  4880.  tst.w d0
  4881.  beq.s donechan3
  4882.  asl.w #6,d1
  4883.  divs d0,d1
  4884.  lsl.w #8,d1
  4885.  adda.w d1,a2
  4886.  move.w d0,$dff0c8
  4887. donechan3:
  4888.  
  4889.  moveq #0,d0
  4890.  moveq #0,d1
  4891.  moveq #0,d2
  4892.  moveq #0,d3
  4893.  moveq #0,d4
  4894.  moveq #0,d5
  4895.  move.w #49,d7
  4896. loop4:
  4897.  move.l (a0)+,d0
  4898.  move.b (a1)+,d1
  4899.  move.b (a1)+,d2
  4900.  move.b (a1)+,d3
  4901.  move.b (a1)+,d4
  4902.  move.b (a2,d3.w),d5
  4903.  swap d5
  4904.  move.b (a2,d1.w),d5
  4905.  asl.l #8,d5
  4906.  move.b (a2,d2.w),d5
  4907.  swap d5
  4908.  move.b (a2,d4.w),d5
  4909.  add.l d5,d0
  4910.  move.l d0,(a3)+
  4911.  dbra d7,loop4
  4912.  
  4913.  tst.b swappedem
  4914.  beq.s .ok23
  4915.  exg a0,a1
  4916. .ok23:
  4917.  
  4918.  cmp.l Samp1endRIGHT,a0
  4919.  blt.s notoffendsamp3
  4920.  move.l #empty,a0
  4921.  move.l #emptyend,Samp1endRIGHT
  4922.  move.b #0,vol1right
  4923.  st RIGHTCHANDATA+1+4
  4924.  move.w #0,RIGHTCHANDATA+2+4
  4925. notoffendsamp3:
  4926.  
  4927.  cmp.l Samp3endRIGHT,a1
  4928.  blt.s notoffendsamp4
  4929.  move.l #empty,a1
  4930.  move.l #emptyend,Samp3endRIGHT
  4931.  move.b #0,vol3right
  4932.  st RIGHTCHANDATA+1+12
  4933.  move.w #0,RIGHTCHANDATA+2+12
  4934. notoffendsamp4:
  4935.  
  4936.  move.l a0,pos1RIGHT
  4937.  move.l a1,pos3RIGHT
  4938.  
  4939.  movem.l (a7)+,d0-d7/a0-a6
  4940.  tst.b counting
  4941.  beq .nostartcounter
  4942.  JSR STARTCOUNT
  4943. .nostartcounter:
  4944.  
  4945.  rte
  4946.  
  4947. ***********************************
  4948. * 4 channel sound routine
  4949. ***********************************
  4950.  
  4951. fourchannel:
  4952.  
  4953.  move.l #$dff000,a6
  4954.  
  4955.  btst #7,intreqrl(a6)
  4956.  beq.s nofinish0
  4957.  move.w #0,LEFTCHANDATA+2
  4958.  st LEFTCHANDATA+1
  4959.  move.l #null,$a0(a6)
  4960.  move.w #100,$a4(a6) 
  4961.  move.w #$0080,intreq(a6)
  4962. nofinish0:
  4963.  
  4964.  
  4965.  tst.b NoiseMade0pLEFT
  4966.  beq.s NoChan0sound
  4967.  
  4968.  move.l Samp0endLEFT,d0
  4969.  move.l pos0LEFT,d1
  4970.  sub.l d1,d0
  4971.  asr.w #1,d0
  4972.  move.w d0,$a4(a6)
  4973.  move.l d1,$a0(a6)
  4974.  move.w #$8201,dmacon(a6)
  4975.  moveq #0,d0
  4976.  move.b vol0left,d0
  4977.  move.w d0,$a8(a6)
  4978.  
  4979. NoChan0sound:
  4980.  
  4981.  btst #0,intreqr(a6)
  4982.  beq.s nofinish1
  4983.  move.w #0,RIGHTCHANDATA+2
  4984.  st RIGHTCHANDATA+1
  4985.  move.l #null,$b0(a6)
  4986.  move.w #100,$b4(a6)
  4987.  move.w #$0100,intreq(a6)
  4988. nofinish1:
  4989.  
  4990.  tst.b NoiseMade0pRIGHT
  4991.  beq.s NoChan1sound
  4992.  
  4993.  move.l Samp0endRIGHT,d0
  4994.  move.l pos0RIGHT,d1
  4995.  sub.l d1,d0
  4996.  asr.w #1,d0
  4997.  move.w d0,$b4(a6)
  4998.  move.l d1,$b0(a6)
  4999.  move.w #$8202,dmacon(a6)
  5000.  moveq #0,d0
  5001.  move.b vol0right,d0
  5002.  move.w d0,$b8(a6)
  5003.  
  5004. NoChan1sound:
  5005.  
  5006.  
  5007.  btst #1,intreqr(a6)
  5008.  beq.s nofinish2
  5009.  move.w #0,RIGHTCHANDATA+2+4
  5010.  st RIGHTCHANDATA+1+4
  5011.  move.l #null,$c0(a6)
  5012.  move.w #100,$c4(a6)
  5013.  move.w #$0200,intreq(a6)
  5014. nofinish2:
  5015.  
  5016.  tst.b NoiseMade1pRIGHT
  5017.  beq.s NoChan2sound
  5018.  
  5019.  move.l Samp1endRIGHT,d0
  5020.  move.l pos1RIGHT,d1
  5021.  sub.l d1,d0
  5022.  asr.w #1,d0
  5023.  move.w d0,$c4(a6)
  5024.  move.l d1,$c0(a6)
  5025.  move.w #$8204,dmacon(a6)
  5026.  moveq #0,d0
  5027.  move.b vol1right,d0
  5028.  move.w d0,$c8(a6)
  5029.  
  5030. NoChan2sound:
  5031.  
  5032.  btst #2,intreqr(a6)
  5033.  beq.s nofinish3
  5034.  move.w #0,LEFTCHANDATA+2+4
  5035.  st LEFTCHANDATA+1+4
  5036.  move.l #null,$d0(a6)
  5037.  move.w #100,$d4(a6)
  5038.  move.w #$0400,intreq(a6)
  5039. nofinish3:
  5040.  
  5041.  tst.b NoiseMade1pLEFT
  5042.  beq.s NoChan3sound
  5043.  
  5044.  move.l Samp1endLEFT,d0
  5045.  move.l pos1LEFT,d1
  5046.  sub.l d1,d0
  5047.  asr.w #1,d0
  5048.  move.w d0,$d4(a6)
  5049.  move.l d1,$d0(a6)
  5050.  move.w #$8208,dmacon(a6)
  5051.  moveq #0,d0
  5052.  move.b vol1left,d0
  5053.  move.w d0,$d8(a6)
  5054.  
  5055. NoChan3sound:
  5056.  
  5057. nomorechannels:
  5058.  
  5059.  move.l NoiseMade0LEFT,NoiseMade0pLEFT
  5060.  move.l #0,NoiseMade0LEFT
  5061.  move.l NoiseMade0RIGHT,NoiseMade0pRIGHT
  5062.  move.l #0,NoiseMade0RIGHT
  5063.  
  5064.  movem.l (a7)+,d0-d7/a0-a6
  5065.  tst.b counting
  5066.  beq .nostartcounter
  5067.  JSR STARTCOUNT
  5068. .nostartcounter:
  5069.  
  5070.  rte
  5071.  
  5072. backbeat: dc.w 0
  5073.  
  5074. Samp0endRIGHT: dc.l emptyend
  5075. Samp1endRIGHT: dc.l emptyend
  5076. Samp2endRIGHT: dc.l emptyend
  5077. Samp3endRIGHT: dc.l emptyend
  5078. Samp0endLEFT: dc.l emptyend
  5079. Samp1endLEFT: dc.l emptyend
  5080. Samp2endLEFT: dc.l emptyend
  5081. Samp3endLEFT: dc.l emptyend
  5082.  
  5083. Aupt0: dc.l null
  5084. Auback0: dc.l null+500
  5085. Aupt2: dc.l null3
  5086. Auback2: dc.l null3+500
  5087. Aupt3: dc.l null4
  5088. Auback3: dc.l null4+500
  5089. Aupt1: dc.l null2
  5090. Auback1: dc.l null2+500
  5091.  
  5092. NoiseMade0LEFT: dc.b 0
  5093. NoiseMade1LEFT: dc.b 0
  5094. NoiseMade2LEFT: dc.b 0
  5095. NoiseMade3LEFT: dc.b 0
  5096. NoiseMade0pLEFT: dc.b 0
  5097. NoiseMade1pLEFT: dc.b 0
  5098. NoiseMade2pLEFT: dc.b 0
  5099. NoiseMade3pLEFT: dc.b 0
  5100. NoiseMade0RIGHT: dc.b 0
  5101. NoiseMade1RIGHT: dc.b 0
  5102. NoiseMade2RIGHT: dc.b 0
  5103. NoiseMade3RIGHT: dc.b 0
  5104. NoiseMade0pRIGHT: dc.b 0
  5105. NoiseMade1pRIGHT: dc.b 0
  5106. NoiseMade2pRIGHT: dc.b 0
  5107. NoiseMade3pRIGHT: dc.b 0
  5108.  
  5109. empty: ds.l 100
  5110. emptyend:
  5111.  
  5112. **************************************
  5113. * I want a routine to calculate all the
  5114. * info needed for the sound player to
  5115. * work, given say position of noise, volume
  5116. * and sample number.
  5117.  
  5118. Samplenum: dc.w 0
  5119. Noisex: dc.w 0
  5120. Noisez: dc.w 0
  5121. Noisevol: dc.w 0
  5122. chanpick: dc.w 0
  5123. IDNUM: dc.w 0
  5124. needleft: dc.b 0
  5125. needright: dc.b 0
  5126. STEREO: dc.b $0
  5127.  
  5128.  even
  5129.  
  5130. CHANNELDATA:
  5131. LEFTCHANDATA:
  5132.  dc.l $FF000000
  5133.  dc.l $00000000
  5134.  dc.l $FF000000
  5135.  dc.l $00000000
  5136. RIGHTCHANDATA:
  5137.  dc.l $FF000000
  5138.  dc.l $00000000
  5139.  dc.l $FF000000
  5140.  dc.l $00000000
  5141.  
  5142. RIGHTPLAYEDTAB: ds.l 20
  5143. LEFTPLAYEDTAB: ds.l 20
  5144.  
  5145. MakeSomeNoise:
  5146.  
  5147. ; Plan for new sound handler:
  5148. ; It is sent a sample number,
  5149. ; a position relative to the
  5150. ; player, an id number and a volume.
  5151. ; Also notifplaying.
  5152.  
  5153. ; indirect inputs are the available
  5154. ; channel flags and whether or not
  5155. ; stereo sound is selected.
  5156.  
  5157. ; the algorithm must decide
  5158. ; whether the new sound is more
  5159. ; important than the ones already
  5160. ; playing. Thus an 'importance'
  5161. ; must be calculated, probably
  5162. ; using volume.
  5163.  
  5164. ; The output needs to be:
  5165.  
  5166. ; Write the pointers and volumes of
  5167. ; the sound channels
  5168.  
  5169.  
  5170.  tst.b notifplaying
  5171.  beq.s dontworry
  5172.  
  5173. ; find if we are already playing
  5174.  
  5175.  move.b IDNUM,d0
  5176.  move.w #7,d1
  5177.  lea CHANNELDATA,a3
  5178. findsameasme
  5179.  tst.b (a3)
  5180.  bne.s notavail
  5181.  cmp.b 1(a3),d0
  5182.  beq SameAsMe
  5183. notavail:
  5184.  add.w #4,a3
  5185.  dbra d1,findsameasme
  5186.  bra dontworry
  5187. SameAsMe
  5188.  rts
  5189. prot7: dc.w 0
  5190.  
  5191. dontworry:
  5192.  
  5193. ; Ok its fine for us to play a sound.
  5194. ; So calculate left/right volume.
  5195.  
  5196.  move.w Noisex,d1
  5197.  muls d1,d1
  5198.  move.w Noisez,d2
  5199.  muls d2,d2
  5200.  move.w #64,d3
  5201.  moveq #1,d0
  5202.  add.l d1,d2
  5203.  beq pastcalc
  5204.  
  5205.  move.w #31,d0
  5206. .findhigh
  5207.  btst d0,d2
  5208.  bne .foundhigh
  5209.  dbra d0,.findhigh
  5210. .foundhigh
  5211.  asr.w #1,d0
  5212.  clr.l d3
  5213.  bset d0,d3
  5214.  move.l d3,d0
  5215.  
  5216.  move.w d0,d3
  5217.  muls d3,d3    ; x*x
  5218.  sub.l d2,d3    ; x*x-a
  5219.  asr.l #1,d3    ; (x*x-a)/2
  5220.  divs d0,d3    ; (x*x-a)/2x
  5221.  sub.w d3,d0    ; second approx
  5222.  bgt .stillnot0
  5223.  move.w #1,d0
  5224. .stillnot0
  5225.  
  5226.  move.w d0,d3
  5227.  muls d3,d3
  5228.  sub.l d2,d3
  5229.  asr.l #1,d3
  5230.  divs d0,d3
  5231.  sub.w d3,d0    ; second approx
  5232.  bgt .stillnot02
  5233.  move.w #1,d0
  5234. .stillnot02
  5235.  
  5236.  move.w #64,d3
  5237.  muls Noisevol,d3
  5238.  asr.w #1,d0
  5239.  addq #1,d0
  5240.  divs d0,d3
  5241.  
  5242.  cmp.w #64,d3
  5243.  ble.s notooloud
  5244.  move.w #64,d3
  5245. notooloud:
  5246.  
  5247. pastcalc:
  5248.  
  5249.     ; d3 contains volume of noise.
  5250.     
  5251.  move.w d3,d4
  5252.  
  5253.  move.w d3,d2
  5254.  muls Noisex,d2
  5255.  add.w d0,d0
  5256.  divs d0,d2
  5257.  
  5258.  bgt.s quietleft
  5259.  add.w d2,d4
  5260.  bge.s donequiet
  5261.  move.w #0,d4
  5262.  bra.s donequiet
  5263. quietleft:
  5264.  sub.w d2,d3
  5265.  bge.s donequiet
  5266.  move.w #0,d3
  5267. donequiet:
  5268.  
  5269. ; d3=leftvol?
  5270. ; d4=rightvol?
  5271.  
  5272.  clr.w needleft
  5273.  
  5274.  cmp.b d3,d4
  5275.  bgt.s RightLouder
  5276.  
  5277. ; Left is louder; is it MUCH louder?
  5278.  
  5279.  st needleft
  5280.  move.w d3,d2
  5281.  sub.w d4,d2
  5282.  cmp.w #32,d2
  5283.  slt needright
  5284.  bra aboutsame
  5285.  
  5286. RightLouder:
  5287.  st needright
  5288.  move.w d4,d2
  5289.  sub.w d3,d2
  5290.  cmp.w #32,d2
  5291.  slt needleft
  5292.  
  5293. aboutsame:
  5294.  
  5295.  tst.b STEREO
  5296.  beq NOSTEREO
  5297.  
  5298. ; Find least important sound on left
  5299.  
  5300.  move.l #0,a2
  5301.  move.l #0,d5
  5302.  move.w #10000,d2
  5303.  move.b IDNUM,d0
  5304.  lea LEFTCHANDATA,a3
  5305.  move.w #3,d1
  5306. FindLeftChannel
  5307.  tst.b (a3)
  5308.  bne.s .notactive
  5309.  cmp.b 1(a3),d0
  5310.  beq.s FOUNDLEFT
  5311.  cmp.w 2(a3),d2
  5312.  blt.s .notactive
  5313.  move.w 2(a3),d2
  5314.  move.l a3,a2
  5315.  move.w d5,d6
  5316.  
  5317. .notactive:
  5318.  add.w #4,a3
  5319.  add.w #1,d5
  5320.  dbra d1,FindLeftChannel
  5321.  move.l a2,a3
  5322.  bra.s gopastleft
  5323. FOUNDLEFT:
  5324.  move.w d5,d6
  5325. gopastleft:
  5326.  tst.l a3
  5327.  bne.s FOUNDALEFT
  5328.  rts
  5329. FOUNDALEFT:
  5330.  
  5331. ; d6 = channel number
  5332.  move.b d0,1(a3)
  5333.  move.w d3,2(a3)
  5334.  
  5335.  move.w Samplenum,d5
  5336.  move.l #SampleList,a3
  5337.  move.l (a3,d5.w*8),a1
  5338.  move.l 4(a3,d5.w*8),a2
  5339.  
  5340.  tst.b d6
  5341.  seq NoiseMade0LEFT
  5342.  beq.s .chan0
  5343.  cmp.b #2,d6
  5344.  slt NoiseMade1LEFT
  5345.  blt .chan1
  5346.  seq NoiseMade2LEFT
  5347.  beq .chan2
  5348.  st NoiseMade3LEFT
  5349.  
  5350.  move.b d5,LEFTPLAYEDTAB+9
  5351.  move.b d3,LEFTPLAYEDTAB+1+9
  5352.  move.b d4,LEFTPLAYEDTAB+2+9
  5353.  move.b d3,vol3left
  5354.  move.l a1,pos3LEFT
  5355.  move.l a2,Samp3endLEFT
  5356.  bra dorightchan
  5357.  
  5358. .chan0: 
  5359.  move.b d5,LEFTPLAYEDTAB
  5360.  move.b d3,LEFTPLAYEDTAB+1
  5361.  move.b d4,LEFTPLAYEDTAB+2
  5362.  move.l a1,pos0LEFT
  5363.  move.l a2,Samp0endLEFT
  5364.  move.b d3,vol0left
  5365.  bra dorightchan
  5366.  
  5367. .chan1:
  5368.  move.b d5,LEFTPLAYEDTAB+3
  5369.  move.b d3,LEFTPLAYEDTAB+1+3
  5370.  move.b d4,LEFTPLAYEDTAB+2+3
  5371.  move.b d3,vol1left
  5372.  move.l a1,pos1LEFT
  5373.  move.l a2,Samp1endLEFT
  5374.  bra dorightchan
  5375.  
  5376. .chan2: 
  5377.  move.b d5,LEFTPLAYEDTAB+6
  5378.  move.b d3,LEFTPLAYEDTAB+1+6
  5379.  move.b d4,LEFTPLAYEDTAB+2+6
  5380.  move.l a1,pos2LEFT
  5381.  move.l a2,Samp2endLEFT
  5382.  move.b d3,vol2left
  5383.  
  5384. dorightchan:
  5385.  
  5386. ; Find least important sound on right
  5387.  
  5388.  move.l #0,a2
  5389.  move.l #0,d5
  5390.  move.w #10000,d2
  5391.  move.b IDNUM,d0
  5392.  lea RIGHTCHANDATA,a3
  5393.  move.w #3,d1
  5394. FindRightChannel
  5395.  tst.b (a3)
  5396.  bne.s .notactive
  5397.  cmp.b 1(a3),d0
  5398.  beq.s FOUNDRIGHT
  5399.  cmp.w 2(a3),d2
  5400.  blt.s .notactive
  5401.  move.w 2(a3),d2
  5402.  move.l a3,a2
  5403.  move.w d5,d6
  5404.  
  5405. .notactive:
  5406.  add.w #4,a3
  5407.  add.w #1,d5
  5408.  dbra d1,FindRightChannel
  5409.  move.l a2,a3
  5410.  bra.s gopastright
  5411. FOUNDRIGHT:
  5412.  move.w d5,d6
  5413. gopastright:
  5414.  tst.l a3
  5415.  bne.s FOUNDARIGHT
  5416.  rts
  5417. FOUNDARIGHT:
  5418.  
  5419. ; d6 = channel number
  5420.  move.b d0,1(a3)
  5421.  move.w d3,2(a3)
  5422.  
  5423.  move.w Samplenum,d5
  5424.  move.l #SampleList,a3
  5425.  move.l (a3,d5.w*8),a1
  5426.  move.l 4(a3,d5.w*8),a2
  5427.  
  5428.  tst.b d6
  5429.  seq NoiseMade0RIGHT
  5430.  beq.s .chan0
  5431.  cmp.b #2,d6
  5432.  slt NoiseMade1RIGHT
  5433.  blt .chan1
  5434.  seq NoiseMade2RIGHT
  5435.  beq .chan2
  5436.  st NoiseMade3RIGHT
  5437.  
  5438.  move.b d5,RIGHTPLAYEDTAB+9
  5439.  move.b d3,RIGHTPLAYEDTAB+1+9
  5440.  move.b d4,RIGHTPLAYEDTAB+2+9
  5441.  move.b d4,vol3right
  5442.  move.l a1,pos3RIGHT
  5443.  move.l a2,Samp3endRIGHT
  5444.  rts
  5445.  
  5446. .chan0: 
  5447.  move.b d5,RIGHTPLAYEDTAB
  5448.  move.b d3,RIGHTPLAYEDTAB+1
  5449.  move.b d4,RIGHTPLAYEDTAB+2
  5450.  move.l a1,pos0RIGHT
  5451.  move.l a2,Samp0endRIGHT
  5452.  move.b d4,vol0right
  5453.  rts
  5454.  
  5455. .chan1:
  5456.  move.b d5,RIGHTPLAYEDTAB+3
  5457.  move.b d3,RIGHTPLAYEDTAB+1+3
  5458.  move.b d4,RIGHTPLAYEDTAB+2+3
  5459.  move.b d3,vol1right
  5460.  move.l a1,pos1RIGHT
  5461.  move.l a2,Samp1endRIGHT
  5462.  rts
  5463.  
  5464. .chan2: 
  5465.  move.b d5,RIGHTPLAYEDTAB+6
  5466.  move.b d3,RIGHTPLAYEDTAB+1+6
  5467.  move.b d4,RIGHTPLAYEDTAB+2+6
  5468.  move.l a1,pos2RIGHT
  5469.  move.l a2,Samp2endRIGHT
  5470.  move.b d3,vol2right
  5471.  rts
  5472.  
  5473. NOSTEREO:
  5474.  move.l #0,a2
  5475.  move.l #0,d5
  5476.  move.w #10000,d2
  5477.  move.b IDNUM,d0
  5478.  lea CHANNELDATA,a3
  5479.  move.w #7,d1
  5480. FindChannel
  5481.  tst.b (a3)
  5482.  bne.s .notactive
  5483.  cmp.b 1(a3),d0
  5484.  beq.s FOUNDCHAN
  5485.  cmp.w 2(a3),d2
  5486.  blt.s .notactive
  5487.  move.w 2(a3),d2
  5488.  move.l a3,a2
  5489.  move.w d5,d6
  5490.  
  5491. .notactive:
  5492.  add.w #4,a3
  5493.  add.w #1,d5
  5494.  dbra d1,FindChannel
  5495.  move.l a2,a3
  5496.  bra.s gopastchan
  5497. FOUNDCHAN:
  5498.  move.w d5,d6
  5499. gopastchan:
  5500.  tst.l a3
  5501.  bne.s FOUNDACHAN
  5502.  rts
  5503. FOUNDACHAN:
  5504.  
  5505. ; d6 = channel number
  5506.  move.b d0,1(a3)
  5507.  move.w d3,2(a3)
  5508.  
  5509.  move.w Samplenum,d5
  5510.  move.l #SampleList,a3
  5511.  move.l (a3,d5.w*8),a1
  5512.  move.l 4(a3,d5.w*8),a2
  5513.  
  5514.  tst.b d6
  5515.  seq NoiseMade0LEFT
  5516.  beq .chan0
  5517.  cmp.b #2,d6
  5518.  slt NoiseMade1LEFT
  5519.  blt .chan1
  5520.  seq NoiseMade2LEFT
  5521.  beq .chan2
  5522.  cmp.b #4,d6
  5523.  slt NoiseMade3LEFT
  5524.  blt .chan3
  5525.  seq NoiseMade0RIGHT
  5526.  beq .chan4
  5527.  cmp.b #6,d6
  5528.  slt NoiseMade1RIGHT
  5529.  blt .chan5
  5530.  seq NoiseMade2RIGHT
  5531.  beq .chan6
  5532.  st NoiseMade3RIGHT
  5533.  
  5534.  move.b d5,RIGHTPLAYEDTAB+9
  5535.  move.b d3,RIGHTPLAYEDTAB+1+9
  5536.  move.b d4,RIGHTPLAYEDTAB+2+9
  5537.  move.b d4,vol3right
  5538.  move.l a1,pos3RIGHT
  5539.  move.l a2,Samp3endRIGHT
  5540.  rts
  5541.  
  5542. .chan3:
  5543.  move.b d5,LEFTPLAYEDTAB+9
  5544.  move.b d3,LEFTPLAYEDTAB+1+9
  5545.  move.b d4,LEFTPLAYEDTAB+2+9
  5546.  move.b d3,vol3left
  5547.  move.l a1,pos3LEFT
  5548.  move.l a2,Samp3endLEFT
  5549.  bra dorightchan
  5550.  
  5551. .chan0: 
  5552.  move.b d5,LEFTPLAYEDTAB
  5553.  move.b d3,LEFTPLAYEDTAB+1
  5554.  move.b d4,LEFTPLAYEDTAB+2
  5555.  move.l a1,pos0LEFT
  5556.  move.l a2,Samp0endLEFT
  5557.  move.b d3,vol0left
  5558.  rts
  5559.  
  5560. .chan1:
  5561.  move.b d5,LEFTPLAYEDTAB+3
  5562.  move.b d3,LEFTPLAYEDTAB+1+3
  5563.  move.b d4,LEFTPLAYEDTAB+2+3
  5564.  move.b d3,vol1left
  5565.  move.l a1,pos1LEFT
  5566.  move.l a2,Samp1endLEFT
  5567.  rts
  5568.  
  5569. .chan2: 
  5570.  move.b d5,LEFTPLAYEDTAB+6
  5571.  move.b d3,LEFTPLAYEDTAB+1+6
  5572.  move.b d4,LEFTPLAYEDTAB+2+6
  5573.  move.l a1,pos2LEFT
  5574.  move.l a2,Samp2endLEFT
  5575.  move.b d3,vol2left
  5576.  rts
  5577.  
  5578. .chan4: 
  5579.  move.b d5,RIGHTPLAYEDTAB
  5580.  move.b d3,RIGHTPLAYEDTAB+1
  5581.  move.b d4,RIGHTPLAYEDTAB+2
  5582.  move.l a1,pos0RIGHT
  5583.  move.l a2,Samp0endRIGHT
  5584.  move.b d4,vol0right
  5585.  rts
  5586.  
  5587. .chan5:
  5588.  move.b d5,RIGHTPLAYEDTAB+3
  5589.  move.b d3,RIGHTPLAYEDTAB+1+3
  5590.  move.b d4,RIGHTPLAYEDTAB+2+3
  5591.  move.b d3,vol1right
  5592.  move.l a1,pos1RIGHT
  5593.  move.l a2,Samp1endRIGHT
  5594.  rts
  5595.  
  5596. .chan6: 
  5597.  move.b d5,RIGHTPLAYEDTAB+6
  5598.  move.b d3,RIGHTPLAYEDTAB+1+6
  5599.  move.b d4,RIGHTPLAYEDTAB+2+6
  5600.  move.l a1,pos2RIGHT
  5601.  move.l a2,Samp2endRIGHT
  5602.  move.b d3,vol2right
  5603.  rts
  5604.  
  5605. SampleList
  5606.  dc.l Scream,EndScream
  5607.  dc.l Shoot,EndShoot
  5608.  dc.l Munch,EndMunch
  5609.  dc.l PooGun,EndPooGun
  5610.  dc.l Collect,EndCollect
  5611. ;5
  5612.  dc.l DoorNoise,EndDoorNoise
  5613.  dc.l 0,0
  5614.  dc.l Stomp,EndStomp
  5615.  dc.l LowScream,EndLowScream
  5616.  dc.l BaddieGun,EndBaddieGun
  5617. ;10
  5618.  dc.l SwitchNoise,EndSwitch
  5619.  dc.l Reload,EndReload
  5620.  dc.l NoAmmo,EndNoAmmo
  5621.  
  5622. saveinters:  
  5623.  dc.w 0
  5624.  
  5625. z: dc.w 10
  5626.  
  5627. notifplaying:
  5628.  dc.w 0
  5629.  
  5630. audpos1: dc.w 0
  5631. audpos1b: dc.w 0
  5632. audpos2: dc.w 0
  5633. audpos2b: dc.w 0
  5634. audpos3: dc.w 0
  5635. audpos3b: dc.w 0
  5636. audpos4: dc.w 0
  5637. audpos4b: dc.w 0
  5638.  
  5639. vol0left: dc.w 0
  5640. vol0right: dc.w 0
  5641. vol1left: dc.w 0
  5642. vol1right: dc.w 0
  5643. vol2left: dc.w 0
  5644. vol2right: dc.w 0
  5645. vol3left: dc.w 0
  5646. vol3right: dc.w 0
  5647.  
  5648. pos: dc.l 0
  5649.  
  5650. pos0LEFT: dc.l empty
  5651. pos1LEFT: dc.l empty
  5652. pos2LEFT: dc.l empty
  5653. pos3LEFT: dc.l empty
  5654. pos0RIGHT: dc.l empty
  5655. pos1RIGHT: dc.l empty
  5656. pos2RIGHT: dc.l empty
  5657. pos3RIGHT: dc.l empty
  5658.  
  5659. numtodo dc.w 0
  5660.  
  5661. npt: dc.w 0
  5662.  
  5663. pretab:
  5664. val SET 0
  5665.  REPT 128
  5666.  dc.b val
  5667. val SET val+1
  5668.  ENDR
  5669. val SET -128
  5670.  REPT 128
  5671.  dc.b val
  5672. val SET val+1
  5673.  ENDR 
  5674.  
  5675. tab:
  5676.  ds.b 256*65
  5677.  
  5678.  
  5679. test: dc.l 0
  5680.  ds.l 30
  5681.  
  5682.  even
  5683. ConstCols:
  5684.  incbin "ConstCols"
  5685.  even
  5686. Smoothscalecols:
  5687. ; incbin "smoothbumppalscaled"
  5688.  even
  5689. SmoothTile:
  5690. ; incbin "smoothbumptile"
  5691.  even
  5692. Bumpscalecols:
  5693. ; incbin "Bumppalscaled"
  5694.  even
  5695. Bumptile:
  5696. ; incbin "bumptile"
  5697.  even
  5698. scalecols: incbin "bytepixpalscaled"
  5699.  even
  5700. floorscalecols: incbin "floorpalscaled"
  5701.  even
  5702. walltiles:
  5703.  incbin "bytepixfile"
  5704.  even
  5705. floortile:
  5706.  incbin "floortile" 
  5707.  even
  5708. wallrouts:
  5709. ; incbin "2x2WallDraw" 
  5710.  CNOP 0,64
  5711. BackPicture:
  5712.  incbin "backfile"
  5713. EndBackPicture:
  5714.  
  5715. drawpt: dc.l colbars2
  5716. olddrawpt: dc.l colbars
  5717. frompt: dc.l 0 
  5718.  
  5719. SineTable:
  5720.  incbin "bigsine"
  5721.  
  5722. angpos: dc.w 0
  5723. angspd: dc.w 0
  5724. flooryoff: dc.w 0
  5725. xoff: dc.l 0
  5726. yoff: dc.l 0
  5727. yvel: dc.l 0
  5728. zoff: dc.l 0
  5729. tyoff: dc.l 0
  5730. xspdval: dc.l 0
  5731. zspdval: dc.l 0
  5732. Zone: dc.w 0
  5733.  
  5734. PLR1: dc.b $ff
  5735.  even
  5736. PLR1_cosval: dc.w 0
  5737. PLR1_sinval: dc.w 0
  5738. PLR1_angpos: dc.w 0
  5739. PLR1_angspd: dc.w 0
  5740. PLR1_xoff: dc.l 0
  5741. PLR1_yoff: dc.l 0
  5742. PLR1_yvel: dc.l 0
  5743. PLR1_zoff: dc.l 0
  5744. PLR1_tyoff: dc.l 0
  5745. PLR1_xspdval: dc.l 0
  5746. PLR1_zspdval: dc.l 0
  5747. PLR1_Zone: dc.w 0
  5748. PLR1_Roompt: dc.l 0
  5749. PLR1_OldRoompt: dc.l 0
  5750. PLR1_PointsToRotatePtr: dc.l 0
  5751. PLR1_ListOfGraphRooms: dc.l 0
  5752. PLR1_oldxoff: dc.l 0
  5753. PLR1_oldzoff: dc.l 0
  5754.  
  5755.  ds.w 4
  5756.  
  5757. PLR1s_cosval: dc.w 0
  5758. PLR1s_sinval: dc.w 0
  5759. PLR1s_angpos: dc.w 0
  5760. PLR1s_angspd: dc.w 0
  5761. PLR1s_xoff: dc.l 0
  5762. PLR1s_yoff: dc.l 0
  5763. PLR1s_yvel: dc.l 0
  5764. PLR1s_zoff: dc.l 0
  5765. PLR1s_tyoff: dc.l 0
  5766. PLR1s_xspdval: dc.l 0
  5767. PLR1s_zspdval: dc.l 0
  5768. PLR1s_Zone: dc.w 0
  5769. PLR1s_Roompt: dc.l 0
  5770. PLR1s_OldRoompt: dc.l 0
  5771. PLR1s_PointsToRotatePtr: dc.l 0
  5772. PLR1s_ListOfGraphRooms: dc.l 0
  5773. PLR1s_oldxoff: dc.l 0
  5774. PLR1s_oldzoff: dc.l 0
  5775.  
  5776.  ds.w 4
  5777.  
  5778. PLR2: dc.b $0
  5779.  even
  5780. PLR2_cosval: dc.w 0
  5781. PLR2_sinval: dc.w 0
  5782. PLR2_angpos: dc.w 0
  5783. PLR2_angspd: dc.w 0
  5784. PLR2_xoff: dc.l 0
  5785. PLR2_yoff: dc.l 0
  5786. PLR2_yvel: dc.l 0
  5787. PLR2_zoff: dc.l 0
  5788. PLR2_tyoff: dc.l 0
  5789. PLR2_xspdval: dc.l 0
  5790. PLR2_zspdval: dc.l 0
  5791. PLR2_Zone: dc.w 0
  5792. PLR2_Roompt: dc.l 0
  5793. PLR2_OldRoompt: dc.l 0
  5794. PLR2_PointsToRotatePtr: dc.l 0
  5795. PLR2_ListOfGraphRooms: dc.l 0
  5796. PLR2_ForwardSpd: dc.w 0
  5797.  
  5798. liftanimtab:
  5799.  
  5800. endliftanimtab:
  5801.  
  5802. glassball:
  5803.  incbin "glassball.inc"
  5804. endglass
  5805. glassballpt: dc.l glassball
  5806.  
  5807. rndtab: ; incbin "randfile"
  5808. endrnd: 
  5809.  
  5810. brightanimtab:
  5811.  dcb.w 200,20
  5812.  dc.w 5
  5813.  dc.w 10,20
  5814.  dc.w 5
  5815.  dcb.w 30,20
  5816.  dc.w 7,10,10,5,10,0,5,6,5,6,5,6,5,6,0
  5817.  dcb.w 40,0
  5818.  dc.w 1,2,3,2,3,2,3,2,3,2,3,2,3,0
  5819.  dcb.w 300,0
  5820.  dc.w 1,0,1,0,2,2,2,5,5,5,5,5,5,5,5,5,6,10
  5821.  dc.w -1
  5822.  
  5823. Roompt: dc.l 0
  5824. OldRoompt: dc.l 0
  5825.  
  5826. *****************************************************************
  5827.  *
  5828.  include "AB3:source/LevelData2"
  5829.  *
  5830. *****************************************************************
  5831.  
  5832.  
  5833. wallpt: dc.l 0
  5834. floorpt: dc.l 0
  5835.  
  5836. Rotated:
  5837.  ds.l 800 
  5838. ObjRotated:
  5839.  ds.l 800
  5840.  
  5841. OnScreen:
  5842.  ds.l 800 
  5843.  
  5844. startwait: dc.w 0
  5845. endwait: dc.w 0
  5846.  
  5847. Faces: incbin "faces2raw"
  5848.  
  5849. *******************************************************************
  5850.  
  5851. consttab:
  5852.  incbin "constantfile"
  5853.  
  5854. *******************************************************************
  5855.  
  5856. darkentab: incbin "darkenedcols"
  5857. brightentab: incbin "brightenfile"
  5858. WorkSpace:
  5859.  ds.l 8192 
  5860. waterfile: incbin "waterfile"
  5861.  
  5862.  SECTION ffff,CODE_C
  5863.  
  5864. nullspr: dc.l 0
  5865.  
  5866.  cnop 0,8
  5867. borders:
  5868.  incbin "leftbord"
  5869.  incbin "rightbord"
  5870.  
  5871. health: incbin "healthstrip"
  5872. Ammunition: incbin "ammostrip"
  5873. healthpal: incbin "healthpal"
  5874. PanelKeys: incbin "greenkey"
  5875.  incbin "redkey"
  5876.  incbin "yellowkey"
  5877.  incbin "bluekey"
  5878.  
  5879. null: ds.w 500
  5880. null2: ds.w 500
  5881. null3: ds.w 500
  5882. null4: ds.w 500
  5883.  
  5884.  
  5885. Blurbfield:
  5886.  
  5887.  dc.w bpl1ptl
  5888. bl1l: dc.w 0
  5889.  dc.w bpl1pth
  5890. bl1h: dc.w 0
  5891.  
  5892.  dc.w diwstart,$2c81
  5893.  dc.w diwstop,$1cc1
  5894.  dc.w ddfstart,$38
  5895.  dc.w ddfstop,$b8
  5896.  dc.w bplcon0,$9201
  5897.  dc.w bplcon1,0
  5898.  dc.w $106,$c40
  5899. blcols:
  5900.  dc.w col0,0
  5901.  dc.w col1,$fff
  5902.  
  5903.  dc.w $108,0
  5904.  dc.w $10a,0
  5905.  
  5906.  dc.w $ffff,$fffe
  5907.  dc.w $ffff,$fffe
  5908.  
  5909. nullline:
  5910.  ds.b 80
  5911.  
  5912. bigfield:    
  5913.                 ; Start of our copper list.
  5914.  
  5915.  dc.w dmacon,$8020
  5916.  dc.w intreq,$8011
  5917.  dc.w $1fc,$f
  5918.  dc.w diwstart
  5919. winstart: dc.w $2cb1
  5920.  dc.w diwstop
  5921. winstop: dc.w $2c91
  5922.  dc.w ddfstart
  5923. fetchstart: dc.w $48
  5924.  dc.w ddfstop
  5925. fetchstop: dc.w $88
  5926.  
  5927. bordercols:
  5928.  incbin "borderpal"
  5929.  
  5930.  dc.w spr0ptl
  5931. s0l:
  5932.  dc.w 0
  5933.  dc.w spr0pth
  5934. s0h:
  5935.  dc.w 0
  5936.  dc.w spr1ptl
  5937. s1l:
  5938.  dc.w 0
  5939.  dc.w spr1pth
  5940. s1h:
  5941.  dc.w 0
  5942.  dc.w spr2ptl
  5943. s2l:
  5944.  dc.w 0
  5945.  dc.w spr2pth
  5946. s2h:
  5947.  dc.w 0
  5948.  dc.w spr3ptl
  5949. s3l:
  5950.  dc.w 0
  5951.  dc.w spr3pth
  5952. s3h:
  5953.  dc.w 0
  5954.  dc.w spr4ptl
  5955. s4l:
  5956.  dc.w 0
  5957.  dc.w spr4pth
  5958. s4h:
  5959.  dc.w 0
  5960.  dc.w spr5ptl
  5961. s5l:
  5962.  dc.w 0
  5963.  dc.w spr5pth
  5964. s5h:
  5965.  dc.w 0
  5966.  dc.w spr6ptl
  5967. s6l:
  5968.  dc.w 0
  5969.  dc.w spr6pth
  5970. s6h:
  5971.  dc.w 0
  5972.  dc.w spr7ptl
  5973. s7l:
  5974.  dc.w 0
  5975.  dc.w spr7pth
  5976. s7h:
  5977.  dc.w 0
  5978.  
  5979.  dc.w $106,$8c42
  5980.  dc.w col0,$0
  5981.  dc.w $106,$c42
  5982.  dc.w col0,0
  5983.  
  5984.  dc.w $106,$c42
  5985.  incbin "borderpal"
  5986.  
  5987.  dc.w bplcon0,$7201
  5988.  dc.w bplcon1
  5989. smoff:
  5990.  dc.w $0
  5991.  
  5992.  dc.w $108
  5993. modulo: dc.w -24
  5994.  dc.w $10a,-24
  5995.  
  5996.  dc.w bpl1pth
  5997. pl1h
  5998.  dc.w 0
  5999.  
  6000.  dc.w bpl1ptl
  6001. pl1l
  6002.  dc.w 0
  6003.  
  6004.  dc.w bpl2pth
  6005. pl2h
  6006.  dc.w 0
  6007.  
  6008.  dc.w bpl2ptl
  6009. pl2l
  6010.  dc.w 0
  6011.  
  6012.  dc.w bpl3pth
  6013. pl3h
  6014.  dc.w 0
  6015.  
  6016.  dc.w bpl3ptl
  6017. pl3l
  6018.  dc.w 0
  6019.  
  6020.  dc.w bpl4pth
  6021. pl4h
  6022.  dc.w 0
  6023.  
  6024.  dc.w bpl4ptl
  6025. pl4l
  6026.  dc.w 0
  6027.  
  6028.  dc.w bpl5pth
  6029. pl5h
  6030.  dc.w 0
  6031.  
  6032.  dc.w bpl5ptl
  6033. pl5l
  6034.  dc.w 0
  6035.  
  6036.  dc.w bpl6pth
  6037. pl6h
  6038.  dc.w 0
  6039.  
  6040.  dc.w bpl6ptl
  6041. pl6l
  6042.  dc.w 0
  6043.  
  6044.  dc.w bpl7pth
  6045. pl7h
  6046.  dc.w 0
  6047.  
  6048.  dc.w bpl7ptl
  6049. pl7l
  6050.  dc.w 0
  6051.  
  6052.  
  6053.  dc.w $1001,$ff00
  6054.  dc.w intreq,$11
  6055. yposcop:
  6056.  dc.w $2a11,$fffe
  6057.  dc.w $8a,0
  6058.  
  6059.  ds.l 104*12
  6060.  
  6061. colbars:
  6062. val SET $2a
  6063.  dcb.l 104*scrheight,$1fe0000
  6064.  dc.w $106,$c42
  6065.  
  6066.  dc.w $80
  6067. pch1:
  6068.  dc.w 0
  6069.  dc.w $82
  6070. pcl1:
  6071.  dc.w 0 
  6072.  dc.w $88,0
  6073.  
  6074.  dc.w $ffff,$fffe       ; End copper list.
  6075.  
  6076.  ds.l 104*12
  6077.  
  6078. colbars2:
  6079. val SET $2a
  6080.  dcb.l 104*scrheight,$1fe0000
  6081.  
  6082.  dc.w $106,$c42
  6083.  
  6084.  dc.w $80
  6085. pch2:
  6086.  dc.w 0
  6087.  dc.w $82
  6088. pcl2:
  6089.  dc.w 0
  6090.  
  6091.  dc.w $88,0
  6092.  
  6093.  dc.w $ffff,$fffe       ; End copper list.
  6094.  
  6095.  ds.l 104*10
  6096.  
  6097. old: dc.l 0
  6098.  
  6099. PanelCop:
  6100.  
  6101.  dc.w $10c,0
  6102.  dc.w bplcon0,$1201
  6103.  dc.w bpl1ptl
  6104. n1l:
  6105.  dc.w 0
  6106.  dc.w bpl1pth
  6107. n1h:
  6108.  dc.w 0
  6109.  dc.w $108,-24
  6110.  incbin "Panelpal"
  6111.  
  6112.  dc.w bpl2pth
  6113. p2h
  6114.  dc.w 0
  6115.  
  6116.  dc.w bpl2ptl
  6117. p2l
  6118.  dc.w 0
  6119.  
  6120.  dc.w bpl3pth
  6121. p3h
  6122.  dc.w 0
  6123.  
  6124.  dc.w bpl3ptl
  6125. p3l
  6126.  dc.w 0
  6127.  
  6128.  dc.w bpl4pth
  6129. p4h
  6130.  dc.w 0
  6131.  dc.w bpl4ptl
  6132. p4l
  6133.  dc.w 0
  6134.  dc.w bpl5pth
  6135. p5h
  6136.  dc.w 0
  6137.  dc.w bpl5ptl
  6138. p5l
  6139.  dc.w 0
  6140.  dc.w bpl6pth
  6141. p6h
  6142.  dc.w 0
  6143.  dc.w bpl6ptl
  6144. p6l
  6145.  dc.w 0
  6146.  dc.w bpl7pth
  6147. p7h
  6148.  dc.w 0
  6149.  dc.w bpl7ptl
  6150. p7l
  6151.  dc.w 0
  6152.  dc.w bpl8pth
  6153. p8h
  6154.  dc.w 0
  6155.  dc.w bpl8ptl
  6156. p8l
  6157.  dc.w 0
  6158.  
  6159.  dc.w $80
  6160. och:
  6161.  dc.w 0
  6162.  dc.w $82
  6163. ocl:
  6164.  dc.w 0
  6165.  
  6166.  dc.w ddfstart,$38
  6167.  dc.w ddfstop,$b8
  6168.  dc.w diwstart,$2c81
  6169.  dc.w diwstop,$2cc1
  6170.  
  6171.  dc.w bplcon0
  6172. Panelcon: dc.w $0211
  6173.  dc.w bpl1pth
  6174. p1h
  6175.  dc.w 0
  6176.  
  6177.  dc.w bpl1ptl
  6178. p1l
  6179.  dc.w 0
  6180.  
  6181.  
  6182.  dc.w $108,40*7
  6183.  dc.w $10a,40*7
  6184.  
  6185.  dc.w $ffff,$fffe
  6186.  
  6187.  dc.w $180,$fff
  6188.  
  6189.  
  6190.  dc.w $f801,$ff00
  6191.  dc.w col1,$50
  6192.  dc.w $f901,$ff00
  6193.  dc.w col1,$90
  6194.  dc.w $fa01,$ff00
  6195.  dc.w col1,$f0
  6196.  dc.w $fb01,$ff00
  6197.  dc.w col1,$f0
  6198.  dc.w $fc01,$ff00
  6199.  dc.w col1,$90
  6200.  dc.w $fd01,$ff00
  6201.  dc.w col1,$50
  6202.  
  6203.  dc.w $fe01,$ff00
  6204.  dc.w col1,$fff
  6205.  
  6206.  dc.w $ffdf,$fffe
  6207.  dc.w $a01,$ff00
  6208.  dc.w bplcon0,$201
  6209.  
  6210.  incbin "faces2cols"
  6211.  dc.w bpl1pth
  6212. f1h
  6213.  dc.w 0
  6214.  
  6215.  dc.w bpl1ptl
  6216. f1l
  6217.  dc.w 0
  6218.  
  6219.  dc.w bpl2pth
  6220. f2h
  6221.  dc.w 0
  6222.  
  6223.  dc.w bpl2ptl
  6224. f2l
  6225.  dc.w 0
  6226.  
  6227.  dc.w bpl3pth
  6228. f3h
  6229.  dc.w 0
  6230.  
  6231.  dc.w bpl3ptl
  6232. f3l
  6233.  dc.w 0
  6234.  
  6235.  dc.w bpl4pth
  6236. f4h
  6237.  dc.w 0
  6238.  dc.w bpl4ptl
  6239. f4l
  6240.  dc.w 0
  6241.  
  6242.  dc.w bpl5pth
  6243. f5h
  6244.  dc.w 0
  6245.  dc.w bpl5ptl
  6246. f5l
  6247.  dc.w 0
  6248.  
  6249.  dc.w $0c01,$ff00
  6250.  dc.w bplcon0,$5201
  6251.   
  6252.  dc.w $ffff,$fffe
  6253.  
  6254.  cnop 0,64
  6255. FacePlace:
  6256.  ds.l 6*32*5
  6257.  
  6258.  
  6259. ********************************************
  6260. * Stuff you don't have to worry about yet. *
  6261. ********************************************
  6262.  
  6263. closeeverything:
  6264.  
  6265.  jsr mt_end
  6266.  
  6267.  move.l #$dff000,a6
  6268.  move.l old,$dff080     ; Restore old copper list.
  6269.  move.l old,d0
  6270.  move.w d0,ocl
  6271.  swap d0
  6272.  move.w d0,och
  6273.  move.w #$8020,dmacon(a6)
  6274.  move.w #$f,dmacon(a6)
  6275.  move.l saveit,$6c.w
  6276.  move.l OLDKINT,$68.w
  6277.  move.w saveinters,d0
  6278.  or.w #$c000,d0
  6279.  move.w d0,intena(a6)
  6280.  clr.w $dff0a8
  6281.  clr.w $dff0b8
  6282.  clr.w $dff0c8
  6283.  clr.w $dff0d8
  6284.  
  6285. ; move.w #3,d0
  6286. ;nonewvbl
  6287. ; btst #5,intreqrl(a6)
  6288. ; beq.s nonewvbl
  6289. ; move.w #$20,intreq(a6)
  6290. ; dbra d0,nonewvbl
  6291.  
  6292. ; move.l oldview,a1
  6293. ; move.l a1,d0
  6294. ; move.l gfxbase,a6
  6295. ; jsr -$de(a6)
  6296.  
  6297.  move.l gfxbase,d0
  6298.  move.l d0,a1
  6299.  move.l 4.w,a6
  6300.  jsr CloseLib(a6)
  6301.  
  6302.  cmp.b #'t',option+1
  6303.  bra.s leaveold
  6304.  move.w #$f8e,$dff1dc
  6305. leaveold:
  6306.  
  6307.  rte
  6308.  
  6309. gfxbase: dc.l 0
  6310. oldview: dc.l 0
  6311. prot6: dc.w 0
  6312.  
  6313. stuff:
  6314.  
  6315.     Lea    gfxname(pc),a1    
  6316.     Moveq.l    #0,d0
  6317.     Move.l    $4.w,a6    
  6318.     Jsr    -$228(a6)
  6319.     Move.l     d0,gfxbase
  6320.     Move.l    d0,a6                Use As Base Reg
  6321.     Move.l    34(a6),oldview
  6322.     move.l 38(a6),old
  6323.  
  6324.  jmp endstuff
  6325.  
  6326. gfxname dc.b "graphics.library",0
  6327.  
  6328.  even
  6329.  
  6330.  
  6331.  cnop 0,64
  6332.  
  6333. Panel:
  6334.  incbin "PanelRaw"
  6335.  
  6336. TimerScr: ds.b 40*64
  6337.  
  6338. scrntab:
  6339.  ds.b 16
  6340. val SET 32
  6341.  REPT 96
  6342.  dc.b val,val,val
  6343. val SET val+1
  6344.  ENDR
  6345.  ds.b 16
  6346.  
  6347.  cnop 0,64
  6348. scrn:
  6349.  
  6350.  dcb.l 8,$33333333
  6351.  dc.l 0
  6352.  dc.l 0
  6353.  
  6354.  dcb.l 8,$0f0f0f0f
  6355.  dc.l 0
  6356.  dc.l 0
  6357.  
  6358.  dcb.l 8,$00ff00ff
  6359.  dc.l 0
  6360.  dc.l 0
  6361.  
  6362.  dcb.l 8,$0000ffff
  6363.  dc.l 0
  6364.  dc.l 0
  6365.  
  6366.  dc.l 0,-1,0,-1,0,-1,0,-1
  6367.  dc.l 0
  6368.  dc.l 0
  6369.  
  6370.  dc.l -1,-1,0,0,-1,-1,0,0
  6371.  dc.l 0
  6372.  dc.l 0
  6373.  
  6374.  dc.l 0,0,-1,-1,-1,-1,-1,-1
  6375.  dc.l 0
  6376.  dc.l 0
  6377.  
  6378. NumTimes: dc.l 0
  6379. TimeCount: dc.l 0
  6380. oldtime: dc.l 0
  6381. counting: dc.b 0
  6382. oktodisplay: dc.b 0
  6383.  
  6384. INITTIMER:
  6385.  move.l #0,TimeCount
  6386.  move.l #0,NumTimes
  6387.  rts
  6388.  
  6389. STARTCOUNT:
  6390.  move.l d0,-(a7)
  6391.  move.l $dff004,d0
  6392.  and.l #$1ffff,d0
  6393.  move.l d0,oldtime
  6394.  st counting
  6395.  move.l (a7)+,d0
  6396.  rts
  6397.  
  6398. STOPCOUNT:
  6399.  move.l d0,-(a7)
  6400.  move.l $dff004,d0
  6401.  and.l #$1ffff,d0
  6402.  
  6403.  sub.l oldtime,d0
  6404.  cmp.l #-256,d0
  6405.  bge.s okcount
  6406.  add.l #313*256,d0
  6407. okcount:
  6408.  add.l d0,TimeCount
  6409.  addq.l #1,NumTimes
  6410.  clr.b counting
  6411.  move.l (a7)+,d0
  6412.  rts
  6413.  
  6414. STOPCOUNTNOADD:
  6415.  move.l d0,-(a7)
  6416.  move.l $dff004,d0
  6417.  and.l #$1ffff,d0
  6418.  
  6419.  sub.l oldtime,d0
  6420.  cmp.l #-256,d0
  6421.  bge.s okcount2
  6422.  add.l #313*256,d0
  6423. okcount2:
  6424.  add.l d0,TimeCount
  6425.  clr.b counting
  6426.  move.l (a7)+,d0
  6427.  rts
  6428.  
  6429. maxbot: dc.w 0
  6430. tstneg: dc.l 0
  6431.  
  6432. STOPTIMER:
  6433.  st oktodisplay
  6434.  rts
  6435.  
  6436. digits: incbin "numbers.inc"
  6437.  
  6438.  
  6439.  Section Sounds,CODE_C
  6440.  
  6441. Scream: incbin "ab3:sounds/Scream"
  6442.  ds.w 100
  6443. EndScream:
  6444. LowScream: incbin "ab3:sounds/LowScream"
  6445.  ds.w 100
  6446. EndLowScream:
  6447. BaddieGun: incbin "ab3:sounds/BaddieGun"
  6448. EndBaddieGun:
  6449. ;bass: incbin "ab3:sounds/backbass+drum"
  6450. ;bassend:
  6451. Shoot: incbin "ab3:sounds/fire!"
  6452. EndShoot:
  6453. Munch: incbin "ab3:sounds/munch"
  6454. EndMunch:
  6455. PooGun: incbin "ab3:sounds/shoot.dm"
  6456. EndPooGun:
  6457. Collect: incbin "ab3:sounds/collect"
  6458. EndCollect:
  6459. DoorNoise: incbin "ab3:sounds/newdoor"
  6460. EndDoorNoise:
  6461. Stomp: incbin "ab3:sounds/footstep3"
  6462. EndStomp:
  6463. SwitchNoise: incbin "ab3:sounds/switch"
  6464. EndSwitch:
  6465. Reload: incbin "ab3:sounds/switch1.SFX"
  6466. EndReload:
  6467. NoAmmo: incbin "ab3:sounds/noammo"
  6468. EndNoAmmo:
  6469.  
  6470.  SECTION music,code_c
  6471.  
  6472. UseAllChannels: dc.w 0
  6473.  
  6474. mt_init:move.l    mt_data,a0
  6475.     move.l    a0,a1
  6476.     add.l    #$3b8,a1
  6477.     moveq    #$7f,d0
  6478.     moveq    #0,d1
  6479. mt_loop:move.l    d1,d2
  6480.     subq.w    #1,d0
  6481. mt_lop2:move.b    (a1)+,d1
  6482.     cmp.b    d2,d1
  6483.     bgt.s    mt_loop
  6484.     dbf    d0,mt_lop2
  6485.     addq.b    #1,d2
  6486.  
  6487.     lea    mt_samplestarts(pc),a1
  6488.     asl.l    #8,d2
  6489.     asl.l    #2,d2
  6490.     add.l    #$43c,d2
  6491.     add.l    a0,d2
  6492.     move.l    d2,a2
  6493.     moveq    #$1e,d0
  6494. mt_lop3:clr.l    (a2)
  6495.     move.l    a2,(a1)+
  6496.     moveq    #0,d1
  6497.     move.w    42(a0),d1
  6498.     asl.l    #1,d1
  6499.     add.l    d1,a2
  6500.     add.l    #$1e,a0
  6501.     dbf    d0,mt_lop3
  6502.  
  6503.     or.b    #$2,$bfe001
  6504.     move.b    #$6,mt_speed
  6505.     clr.w    $dff0a8
  6506.     clr.w    $dff0b8
  6507.     clr.w    $dff0c8
  6508.     clr.w    $dff0d8
  6509.     clr.b    mt_songpos
  6510.     clr.b    mt_counter
  6511.     clr.w    mt_pattpos
  6512.     rts
  6513.  
  6514. mt_end:    clr.w    $dff0a8
  6515.     clr.w    $dff0b8
  6516.     clr.w    $dff0c8
  6517.     clr.w    $dff0d8
  6518.     move.w    #$f,$dff096
  6519.     rts
  6520.  
  6521. mt_music:
  6522.     movem.l    d0-d4/a0-a3/a5-a6,-(a7)
  6523.     move.l    mt_data,a0
  6524.     addq.b    #$1,mt_counter
  6525.     move.b    mt_counter,D0
  6526.     cmp.b    mt_speed,D0
  6527.     blt.s    mt_nonew
  6528.     clr.b    mt_counter
  6529.     bra    mt_getnew
  6530.  
  6531. mt_nonew:
  6532.     lea    mt_voice1(pc),a6
  6533.     lea    $dff0a0,a5
  6534.     bsr    mt_checkcom
  6535.     lea    mt_voice2(pc),a6
  6536.     lea    $dff0b0,a5
  6537.     bsr    mt_checkcom
  6538.     tst.b UseAllChannels
  6539.     beq mt_endr
  6540.      lea    mt_voice3(pc),a6
  6541.     lea    $dff0c0,a5
  6542.     bsr    mt_checkcom
  6543.     lea    mt_voice4(pc),a6
  6544.     lea    $dff0d0,a5
  6545.     bsr    mt_checkcom
  6546.     bra    mt_endr
  6547.  
  6548. mt_arpeggio:
  6549.     moveq    #0,d0
  6550.     move.b    mt_counter,d0
  6551.     divs    #$3,d0
  6552.     swap    d0
  6553.     cmp.w    #$0,d0
  6554.     beq.s    mt_arp2
  6555.     cmp.w    #$2,d0
  6556.     beq.s    mt_arp1
  6557.  
  6558.     moveq    #0,d0
  6559.     move.b    $3(a6),d0
  6560.     lsr.b    #4,d0
  6561.     bra.s    mt_arp3
  6562. mt_arp1:moveq    #0,d0
  6563.     move.b    $3(a6),d0
  6564.     and.b    #$f,d0
  6565.     bra.s    mt_arp3
  6566. mt_arp2:move.w    $10(a6),d2
  6567.     bra.s    mt_arp4
  6568. mt_arp3:asl.w    #1,d0
  6569.     moveq    #0,d1
  6570.     move.w    $10(a6),d1
  6571.     lea    mt_periods(pc),a0
  6572.     moveq    #$24,d7
  6573. mt_arploop:
  6574.     move.w    (a0,d0.w),d2
  6575.     cmp.w    (a0),d1
  6576.     bge.s    mt_arp4
  6577.     addq.l    #2,a0
  6578.     dbf    d7,mt_arploop
  6579.     rts
  6580. mt_arp4:move.w    d2,$6(a5)
  6581.     rts
  6582.  
  6583. mt_getnew:
  6584.     move.l    mt_data,a0
  6585.     move.l    a0,a3
  6586.     move.l    a0,a2
  6587.     add.l    #$c,a3
  6588.     add.l    #$3b8,a2
  6589.     add.l    #$43c,a0
  6590.  
  6591.     moveq    #0,d0
  6592.     move.l    d0,d1
  6593.     move.b    mt_songpos,d0
  6594.     move.b    (a2,d0.w),d1
  6595.     asl.l    #8,d1
  6596.     asl.l    #2,d1
  6597.     add.w    mt_pattpos,d1
  6598.     clr.w    mt_dmacon
  6599.  
  6600.     lea    $dff0a0,a5
  6601.     lea    mt_voice1(pc),a6
  6602.     bsr.s    mt_playvoice
  6603.     lea    $dff0b0,a5
  6604.     lea    mt_voice2(pc),a6
  6605.     bsr.s    mt_playvoice
  6606.     tst.b UseAllChannels
  6607.     beq mt_setdma
  6608.     lea    $dff0c0,a5
  6609.     lea    mt_voice3(pc),a6
  6610.     bsr.s    mt_playvoice
  6611.     lea    $dff0d0,a5
  6612.     lea    mt_voice4(pc),a6
  6613.     bsr.s    mt_playvoice
  6614.     bra    mt_setdma
  6615.  
  6616. mt_playvoice:
  6617.     move.l    (a0,d1.l),(a6)
  6618.     addq.l    #4,d1
  6619.     moveq    #0,d2
  6620.     move.b    $2(a6),d2
  6621.     and.b    #$f0,d2
  6622.     lsr.b    #4,d2
  6623.     move.b    (a6),d0
  6624.     and.b    #$f0,d0
  6625.     or.b    d0,d2
  6626.     tst.b    d2
  6627.     beq.s    mt_setregs
  6628.     moveq    #0,d3
  6629.     lea    mt_samplestarts(pc),a1
  6630.     move.l    d2,d4
  6631.     subq.l    #$1,d2
  6632.     asl.l    #2,d2
  6633.     mulu    #$1e,d4
  6634.     move.l    (a1,d2.l),$4(a6)
  6635.     move.w    (a3,d4.l),$8(a6)
  6636.     move.w    $2(a3,d4.l),$12(a6)
  6637.     move.w    $4(a3,d4.l),d3
  6638.     tst.w    d3
  6639.     beq.s    mt_noloop
  6640.     move.l    $4(a6),d2
  6641.     asl.w    #1,d3
  6642.     add.l    d3,d2
  6643.     move.l    d2,$a(a6)
  6644.     move.w    $4(a3,d4.l),d0
  6645.     add.w    $6(a3,d4.l),d0
  6646.     move.w    d0,8(a6)
  6647.     move.w    $6(a3,d4.l),$e(a6)
  6648.     move.w    $12(a6),d0
  6649.     asr.w #2,d0
  6650.     move.w d0,$8(a5)
  6651.     bra.s    mt_setregs
  6652. mt_noloop:
  6653.     move.l    $4(a6),d2
  6654.     add.l    d3,d2
  6655.     move.l    d2,$a(a6)
  6656.     move.w    $6(a3,d4.l),$e(a6)
  6657.     move.w    $12(a6),d0
  6658.     asr.w #2,d0
  6659.     move.w d0,$8(a5)
  6660. mt_setregs:
  6661.     move.w    (a6),d0
  6662.     and.w    #$fff,d0
  6663.     beq    mt_checkcom2
  6664.     move.b    $2(a6),d0
  6665.     and.b    #$F,d0
  6666.     cmp.b    #$3,d0
  6667.     bne.s    mt_setperiod
  6668.     bsr    mt_setmyport
  6669.     bra    mt_checkcom2
  6670. mt_setperiod:
  6671.     move.w    (a6),$10(a6)
  6672.     and.w    #$fff,$10(a6)
  6673.     move.w    $14(a6),d0
  6674.     move.w    d0,$dff096
  6675.     clr.b    $1b(a6)
  6676.  
  6677.     move.l    $4(a6),(a5)
  6678.     move.w    $8(a6),$4(a5)
  6679.     move.w    $10(a6),d0
  6680.     and.w    #$fff,d0
  6681.     move.w    d0,$6(a5)
  6682.     move.w    $14(a6),d0
  6683.     or.w    d0,mt_dmacon
  6684.     bra    mt_checkcom2
  6685.  
  6686. mt_setdma:
  6687.      move.w #250,d0
  6688. mt_wait:
  6689.      add.w #1,testchip
  6690.      dbra d0,mt_wait
  6691.     move.w    mt_dmacon,d0
  6692.     or.w    #$8000,d0
  6693.     and.w #%1111111111110011,d0
  6694.     move.w    d0,$dff096
  6695.     move.w #250,d0
  6696. mt_wait2:
  6697.     add.w #1,testchip
  6698.     dbra    d0,mt_wait2
  6699.     lea    $dff000,a5
  6700.     tst.b UseAllChannels
  6701.     beq.s noall
  6702.     lea    mt_voice4(pc),a6
  6703.     move.l    $a(a6),$d0(a5)
  6704.     move.w    $e(a6),$d4(a5)
  6705.     lea    mt_voice3(pc),a6
  6706.     move.l    $a(a6),$c0(a5)
  6707.     move.w    $e(a6),$c4(a5)
  6708. noall:
  6709.     lea    mt_voice2(pc),a6
  6710.     move.l    $a(a6),$b0(a5)
  6711.     move.w    $e(a6),$b4(a5)
  6712.     lea    mt_voice1(pc),a6
  6713.     move.l    $a(a6),$a0(a5)
  6714.     move.w    $e(a6),$a4(a5)
  6715.  
  6716.     add.w    #$10,mt_pattpos
  6717.     cmp.w    #$400,mt_pattpos
  6718.     bne.s    mt_endr
  6719. mt_nex:    clr.w    mt_pattpos
  6720.     clr.b    mt_break
  6721.     addq.b    #1,mt_songpos
  6722.     and.b    #$7f,mt_songpos
  6723.     move.b    mt_songpos,d1
  6724. ;    cmp.b    mt_data+$3b6,d1
  6725. ;    bne.s    mt_endr
  6726. ;    move.b    mt_data+$3b7,mt_songpos
  6727. mt_endr:tst.b    mt_break
  6728.     bne.s    mt_nex
  6729.     movem.l    (a7)+,d0-d4/a0-a3/a5-a6
  6730.     rts
  6731.  
  6732. mt_setmyport:
  6733.     move.w    (a6),d2
  6734.     and.w    #$fff,d2
  6735.     move.w    d2,$18(a6)
  6736.     move.w    $10(a6),d0
  6737.     clr.b    $16(a6)
  6738.     cmp.w    d0,d2
  6739.     beq.s    mt_clrport
  6740.     bge.s    mt_rt
  6741.     move.b    #$1,$16(a6)
  6742.     rts
  6743. mt_clrport:
  6744.     clr.w    $18(a6)
  6745. mt_rt:    rts
  6746.  
  6747. mt_myport:
  6748.     move.b    $3(a6),d0
  6749.     beq.s    mt_myslide
  6750.     move.b    d0,$17(a6)
  6751.     clr.b    $3(a6)
  6752. mt_myslide:
  6753.     tst.w    $18(a6)
  6754.     beq.s    mt_rt
  6755.     moveq    #0,d0
  6756.     move.b    $17(a6),d0
  6757.     tst.b    $16(a6)
  6758.     bne.s    mt_mysub
  6759.     add.w    d0,$10(a6)
  6760.     move.w    $18(a6),d0
  6761.     cmp.w    $10(a6),d0
  6762.     bgt.s    mt_myok
  6763.     move.w    $18(a6),$10(a6)
  6764.     clr.w    $18(a6)
  6765. mt_myok:move.w    $10(a6),$6(a5)
  6766.     rts
  6767. mt_mysub:
  6768.     sub.w    d0,$10(a6)
  6769.     move.w    $18(a6),d0
  6770.     cmp.w    $10(a6),d0
  6771.     blt.s    mt_myok
  6772.     move.w    $18(a6),$10(a6)
  6773.     clr.w    $18(a6)
  6774.     move.w    $10(a6),$6(a5)
  6775.     rts
  6776.  
  6777. mt_vib:    move.b    $3(a6),d0
  6778.     beq.s    mt_vi
  6779.     move.b    d0,$1a(a6)
  6780.  
  6781. mt_vi:    move.b    $1b(a6),d0
  6782.     lea    mt_sin(pc),a4
  6783.     lsr.w    #$2,d0
  6784.     and.w    #$1f,d0
  6785.     moveq    #0,d2
  6786.     move.b    (a4,d0.w),d2
  6787.     move.b    $1a(a6),d0
  6788.     and.w    #$f,d0
  6789.     mulu    d0,d2
  6790.     lsr.w    #$6,d2
  6791.     move.w    $10(a6),d0
  6792.     tst.b    $1b(a6)
  6793.     bmi.s    mt_vibmin
  6794.     add.w    d2,d0
  6795.     bra.s    mt_vib2
  6796. mt_vibmin:
  6797.     sub.w    d2,d0
  6798. mt_vib2:move.w    d0,$6(a5)
  6799.     move.b    $1a(a6),d0
  6800.     lsr.w    #$2,d0
  6801.     and.w    #$3c,d0
  6802.     add.b    d0,$1b(a6)
  6803.     rts
  6804.  
  6805. mt_nop:    move.w    $10(a6),$6(a5)
  6806.     rts
  6807.  
  6808.  include "ab3:source/password_reloc.s"
  6809.  
  6810. mt_checkcom:
  6811.     move.w    $2(a6),d0
  6812.     and.w    #$fff,d0
  6813.     beq.s    mt_nop
  6814.     move.b    $2(a6),d0
  6815.     and.b    #$f,d0
  6816.     tst.b    d0
  6817.     beq    mt_arpeggio
  6818.     cmp.b    #$1,d0
  6819.     beq.s    mt_portup
  6820.     cmp.b    #$2,d0
  6821.     beq    mt_portdown
  6822.     cmp.b    #$3,d0
  6823.     beq    mt_myport
  6824.     cmp.b    #$4,d0
  6825.     beq    mt_vib
  6826.     move.w    $10(a6),$6(a5)
  6827.     cmp.b    #$a,d0
  6828.     beq.s    mt_volslide
  6829.     rts
  6830.  
  6831. mt_volslide:
  6832.     moveq    #0,d0
  6833.     move.b    $3(a6),d0
  6834.     lsr.b    #4,d0
  6835.     tst.b    d0
  6836.     beq.s    mt_voldown
  6837.     add.w    d0,$12(a6)
  6838.     cmp.w    #$40,$12(a6)
  6839.     bmi.s    mt_vol2
  6840.     move.w    #$40,$12(a6)
  6841. mt_vol2:move.w    $12(a6),d0
  6842.     asr.w #2,d0
  6843.     move.w d0,$8(a5)
  6844.     rts
  6845.  
  6846. mt_voldown:
  6847.     moveq    #0,d0
  6848.     move.b    $3(a6),d0
  6849.     and.b    #$f,d0
  6850.     sub.w    d0,$12(a6)
  6851.     bpl.s    mt_vol3
  6852.     clr.w    $12(a6)
  6853. mt_vol3:move.w    $12(a6),d0
  6854.     asr.w #2,d0
  6855.     move.w d0,$8(a5)
  6856.     rts
  6857.  
  6858. mt_portup:
  6859.     moveq    #0,d0
  6860.     move.b    $3(a6),d0
  6861.     sub.w    d0,$10(a6)
  6862.     move.w    $10(a6),d0
  6863.     and.w    #$fff,d0
  6864.     cmp.w    #$71,d0
  6865.     bpl.s    mt_por2
  6866.     and.w    #$f000,$10(a6)
  6867.     or.w    #$71,$10(a6)
  6868. mt_por2:move.w    $10(a6),d0
  6869.     and.w    #$fff,d0
  6870.     move.w    d0,$6(a5)
  6871.     rts
  6872.  
  6873. mt_portdown:
  6874.     clr.w    d0
  6875.     move.b    $3(a6),d0
  6876.     add.w    d0,$10(a6)
  6877.     move.w    $10(a6),d0
  6878.     and.w    #$fff,d0
  6879.     cmp.w    #$358,d0
  6880.     bmi.s    mt_por3
  6881.     and.w    #$f000,$10(a6)
  6882.     or.w    #$358,$10(a6)
  6883. mt_por3:move.w    $10(a6),d0
  6884.     and.w    #$fff,d0
  6885.     move.w    d0,$6(a5)
  6886.     rts
  6887.  
  6888. mt_checkcom2:
  6889.     move.b    $2(a6),d0
  6890.     and.b    #$f,d0
  6891.     cmp.b    #$e,d0
  6892.     beq.s    mt_setfilt
  6893.     cmp.b    #$d,d0
  6894.     beq.s    mt_pattbreak
  6895.     cmp.b    #$b,d0
  6896.     beq.s    mt_posjmp
  6897.     cmp.b    #$c,d0
  6898.     beq.s    mt_setvol
  6899.     cmp.b    #$f,d0
  6900.     beq.s    mt_setspeed
  6901.     rts
  6902.  
  6903. mt_setfilt:
  6904.     move.b    $3(a6),d0
  6905.     and.b    #$1,d0
  6906.     asl.b    #$1,d0
  6907.     and.b    #$fd,$bfe001
  6908.     or.b    d0,$bfe001
  6909.     rts
  6910. mt_pattbreak:
  6911.     not.b    mt_break
  6912.     rts
  6913. mt_posjmp:
  6914.     st reachedend
  6915.     move.b    $3(a6),d0
  6916.     subq.b    #$1,d0
  6917.     move.b    d0,mt_songpos
  6918.     not.b    mt_break
  6919.     rts
  6920. mt_setvol:
  6921.     cmp.b    #$40,$3(a6)
  6922.     ble.s    mt_vol4
  6923.     move.b    #$40,$3(a6)
  6924. mt_vol4:move.b    $3(a6),d0
  6925.     asr.w #2,d0
  6926.     move.w d0,$8(a5)
  6927.     rts
  6928. mt_setspeed:
  6929.     cmp.b    #$1f,$3(a6)
  6930.     ble.s    mt_sets
  6931.     move.b    #$1f,$3(a6)
  6932. mt_sets:move.b    $3(a6),d0
  6933.     beq.s    mt_rts2
  6934.     move.b    d0,mt_speed
  6935.     clr.b    mt_counter
  6936. mt_rts2:rts
  6937.  
  6938. mt_sin:
  6939.  DC.b $00,$18,$31,$4a,$61,$78,$8d,$a1,$b4,$c5,$d4,$e0,$eb,$f4,$fa,$fd
  6940.  DC.b $ff,$fd,$fa,$f4,$eb,$e0,$d4,$c5,$b4,$a1,$8d,$78,$61,$4a,$31,$18
  6941.  
  6942. prot5: dc.w 0
  6943.  
  6944. mt_periods:
  6945.  DC.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c,$023a,$021a,$01fc,$01e0
  6946.  DC.w $01c5,$01ac,$0194,$017d,$0168,$0153,$0140,$012e,$011d,$010d,$00fe
  6947.  DC.w $00f0,$00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097,$008f,$0087
  6948.  DC.w $007f,$0078,$0071,$0000,$0000
  6949.  
  6950. reachedend: dc.b 0
  6951. mt_speed:    DC.b    6
  6952. mt_songpos:    DC.b    0
  6953. mt_pattpos:    DC.w    0
  6954. mt_counter:    DC.b    0
  6955.  
  6956. mt_break:    DC.b    0
  6957. mt_dmacon:    DC.w    0
  6958. mt_samplestarts:DS.L    $1f
  6959. mt_voice1:    DS.w    10
  6960.         DC.w    1
  6961.         DS.w    3
  6962. mt_voice2:    DS.w    10
  6963.         DC.w    2
  6964.         DS.w    3
  6965. mt_voice3:    DS.w    10
  6966.         DC.w    4
  6967.         DS.w    3
  6968. mt_voice4:    DS.w    10
  6969.         DC.w    8
  6970.         DS.w    3
  6971.  
  6972. testchip: dc.w 0
  6973.  
  6974. ;/* End of File */
  6975. mt_data: dc.l 0
  6976.  
  6977. ingame: incbin "ab3:includes/ingame"
  6978. gameover: incbin "ab3:includes/gameover"
  6979. welldone: incbin "ab3:includes/welldone"
  6980.